DAJ DAJ - 2 months ago 5x
PHP Question

How do I access specific values in my xml?

Let's assume I have simple XML, such as:

<person id="52">
<person id="53">

I use
to load the file.

How do I reference the name of person with id 53, without iterating through looking for the person?


Use xpath() to search for the matching element.

$person = $xml->xpath("/people/person[@id='53']")[0];