Wednesday, 12 October 2016

XML : Parsing PHP using attribute value in node instead of order of node

Example of XML

  <book name="Queen" id="xxxx0">  <descriptions>  <description synopsis="bla bla bla"/>  </descriptions>  </book>      <book name="King" id="xxxx7">  <descriptions>  <description synopsis="snu snu snu"/>  </descriptions>  </book>    

and so on...

Right now, I can parse using simplexml_load_file like this:

  echo $xml->book[0]['name']."<br>";    echo $xml->book[1]['name']."<br>";    

How do I parse using the id value instead of the order of the attribute book?

No comments:

Post a Comment