ballhogjoni Posted July 19, 2007 Share Posted July 19, 2007 why is this code not printing the xml to the browser? <?php $file = "Sitemap/sitemap.xml"; $depth = array(); function startElement($parser, $name, $attrs) { global $depth; for ($i = 0; $i < $depth[$parser]; $i++) { echo " "; } echo "$name\n"; $depth[$parser]++; } function endElement($parser, $name) { global $depth; $depth[$parser]--; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); ?> Link to comment https://forums.phpfreaks.com/topic/60778-xml-to-php-not-showing-data/ Share on other sites More sharing options...
dbo Posted July 19, 2007 Share Posted July 19, 2007 I'd help you but I just started tinkering with PHP's XML parsing yesterday Previously had done it in Java, Perl, Javascript, ASP.NET... but was my first go around on this. There's a pretty decent little tutorial on here I think: http://www.phpfreaks.com/tutorials/44/0.php That's the one I used and was able to get what I wanted accomplished. Link to comment https://forums.phpfreaks.com/topic/60778-xml-to-php-not-showing-data/#findComment-302416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.