Greetings.

I've been RTFM all morning and for the live of me can't figure out how
to relate the element name to its data, e.g. if the element name is
"fullname" and the data is "John Doe' how do I achieve $fullname =
"John Doe" .... I must not be understanding how xml_parse works, and
my searches have turned up nothing.

Any help would be appreciated.

thanks.




function startElement($xml_parser, $name, $attributes) { print("<p><i>Encountered Start Element For: </i>$name\n"); } function endElement($xml_parser, $name) { print("<p><i>Encountered End Element For: <i/>$name\n"); } function characterData($xml_parser, $data) { if ($data != "\n") { $data = ereg_replace ("\:", "&", $data); print ("<p><i>Encountered Character Data: </i>$data\n"); } } function load_data($file) { $fh = fopen($file, "r") or die ("<p>COULD NOT OPEN FILE!"); $data = fread($fh, filesize($file)); return $data; } $xml_parser = xml_parser_create(); xml_set_element_handler ($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parse($xml_parser, load_data($file)) or die ("<p>ERROR PARSING XML!"); xml_parser_free($xml_parser) ;




------------------------ Yahoo! Groups Sponsor --


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to