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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -