php - I cant figure out how to parse this xml file with simplexml -
this xml file
<diseases> <a> <name>disease1</name> <symptoms>pain</symptoms> <treatment></treatment> </a> <a> <name>disease2</name> <symptoms>blood</symptoms> <treatment></treatment> </a> </diseases>
and php follow. php gets variable $q disease name , stristr() name in of child nodes. once found want able display nodes associated disease name symptoms , treatment.
` <?php $q = $_get["q"]; $xml = simplexml_load_file('disease.xml'); foreach ($xml->a $disease_and_childnodes) { if (stristr($disease_and_childnodes->children(),$q)) { $result = $disease_and_childnodes->xpath('.'); print_r($result); //need print childnodes of array instead } } ?>`
so using xpath found node has disease info. if print_r array. how display child nodes 1 line @ time. node $result variable now.
Comments
Post a Comment