XML : PHP - Xpath get node by value

I have this XML:

  <root>    <experiment accessCount="1" downloadCount="1">alfa</experiment>    <experiment accessCount="1" downloadCount="1">beta</experiment>  </root>    

And I would like to detect, if the node experiment with value alfa exists. But this php code is returning to me all values.

      $this->xml = simplexml_load_file("data/stats.xml") or die("Error: Cannot create object");      $node = $this->xml->xpath("/root[experiment='alfa']");    

Where am I wrong? Thanks everyone.

No comments:

Post a Comment