Jump to content

XML PArser


mithu_sree

Recommended Posts

<?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

  • 7 months later...
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...