[thelist] PHP & XML

Burhan Khalid burhankhalid at members.evolt.org
Sun Jun 9 19:20:01 CDT 2002


Hello All :

	I'm trying to read a XML file in PHP. Things are going good, I
can read the file (and display it, using the example from php.net)...but
that's all I can do. I need to figure out how to get a certain element's
data. For example, if the tag is TITLE, I need to store the data
somewhere. How do I access this information? How do I get the
startElement function to call the characterData function for a certain
tag type? Is this even possible?

Thanks,
Burhan

Here is the code :

[ snip ]
function startElement($parser, $name, $attribs) {
	print "&lt;<font color=\"#0000cc\">$name</font>";
    if (sizeof($attribs)) {
        while (list($k, $v) = each($attribs)) {
            print " <font color=\"#009900\">$k</font>=\"<font
                   color=\"#990000\">$v</font>\"";
        }
    }
    print "&gt;";
}

function endElement($parser, $name) {
    print "&lt;/<font color=\"#0000cc\">$name</font>&gt;";
}

function characterData($parser, $data) {
    print "<b>$data</b>";
}
[ snip ]





More information about the thelist mailing list