nadeemshafi9 Posted February 24, 2009 Share Posted February 24, 2009 my current function can only output the entire XML document i am having a hard time trying to searhc the titles in the XML and then output node that contains the search arg i need to mod the below to only output if title contains args, i have tried a few ways but have reverted to this full output, ihave tried moving back and forward with no success <?php final public static function all( $args ){ $xml = new XMLReader(); $xml->open('music.xml'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; // i need to use args to limit the output to the nodes that contain args in there title while ($xml->read()) { if($xml->nodeType == XMLREADER::ELEMENT) echo "<".$xml->localName.">"; echo $xml->value; if($xml->nodeType == XMLREADER::END_ELEMENT) echo "</".$xml->localName.">"; } $xml->close(); } ?> xml file <?xml version="1.0" encoding="UTF-8" ?> <music> <file name="1"> <title>1</title> <filename>1.mp3</filename> </file> <file name="2"> <title>2</title> <filename>2.mp3</filename> </file> <file name="3"> <title>3</title> <filename>3.mp3</filename> </file> <file name="4"> <title>4</title> <filename>4.mp3</filename> </file> </music> any help much appreciated 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.