mithu_sree Posted January 6, 2007 Share Posted January 6, 2007 <?php function parse_xml_file(){ global $xml_file, $vals, $index; $xml_parser = xml_parser_create(); if (!($fp = fopen($xml_file, "r"))) { die("could not open XML input"); } $data = fread($fp, filesize($xml_file)); fclose($fp); $xml_parser = xml_parser_create(); xml_parse_into_struct($xml_parser, $data, $vals, $index); xml_parser_free($xml_parser);}?> the inpur xml file contains<?xml ..?><tagA> <t1> ... </t1> <t2> .... </t2></tagA><tagB> <t3>.... </t3></tagB>And The parser stoped after </tagA>What shoud I do to entair tags get parsed? Link to comment Share on other sites More sharing options...
mandaksk Posted January 7, 2007 Share Posted January 7, 2007 Your xml contains 2 root nodes which is giving the strange result. As per my knowledge there should be only one root node. A simple suggestion is to put it like this.<tag><tagA>...</tagA><tagB>...</tagB></tag>Also PHP will recognize only one root node and not more. Hope you got clarified.-Krishna Srikanthhttp://www.krishnasrikanth.com Link to comment Share on other sites More sharing options...
mithu_sree Posted January 8, 2007 Author Share Posted January 8, 2007 Any other technique to continue parsing with out mordifying my input xml file? Link to comment Share on other sites More sharing options...
mandaksk Posted August 28, 2007 Share Posted August 28, 2007 Any other technique to continue parsing with out mordifying my input xml file?There should be no other technique. Because the XML standard itself says.. " there should be only one root and other elements should be the nodes of the single root.." also the specification for parser also says ".. the parser should stop parsing the xml file that violates the rules of XML.."The xml code you are generating doesn't comply with XML standards, which say, "there should be only one root".. and yours has two roots. So obviously the parser stopped after first root. Manda Krishna Srikanthhttp://www.krishnasrikanth.com Link to comment Share on other sites More sharing options...
Synook Posted August 28, 2007 Share Posted August 28, 2007 Well, if you really wanted to, then you could write your own parser using the file functions in conjunction with regular expressions, but I would say that is a waste of time. Just add a root node such as <tags> and you will be fine! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now