DAJ DAJ - 1 year ago 110
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?

Answer Source

Use xpath() to search for the matching element.

$person = $xml->xpath("/people/person[@id='53']")[0];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download