Source for file xml2html.php
Documentation is available at xml2html.php
Shows a basic example of parsing an XML data set of the type generated by
phpMyAdmin into an HTML table
# require_once 'XML/SaxFilters.php'; // This is the normal way to do it
# Done to help development
if ( !@include_once 'XML/SaxFilters.php' ) {
define ('XML_SAXFILTERS', '../../');
include_once XML_SAXFILTERS . 'SaxFilters.php';
//----------------------------------------------------------------------------
* Filter for converting an XML data set to HTML
/* implements XML_SaxFilters_FilterInterface */
* Switch to determine if we're in a dataset row
* The current column name
* Array of data from a row
// Include the writer output class
// Instantiate the FileWriter
// Set the writer that the filter will use
$writer->write ("<table>\n");
$writer->write (" <caption>The Found Fathers</caption>\n");
$writer->write (" <tr>\n");
$writer->write (" <th>First Name</th>\n <th>Last Name</th>\n");
$writer->write (" </tr>\n");
function open(& $name,& $attribs)
if ( $name == 'founding_fathers' )
$this->writer->write (" <tr>\n");
if ( $name == 'founding_fathers' )
$this->writer->write (" </tr>\n");
$this->writer->write (" <td>". $data. "</td>\n");
$this->writer->write ("</table>\n");
//----------------------------------------------------------------------------
// Create ExpatParser, telling it to use a File stream on founding_fathers.xml
// Assign the DataSetFilter to the parser
// Parse the XML document
// Display the written file
Documentation generated on Mon, 11 Mar 2019 10:15:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|