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); ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.