| | | Using XPath and DOM |
|
|
$dom = new DOMDocument;
$dom->load('address-book.xml');
$xpath = new DOMXPath($dom);
$email = $xpath->query('/address-book/person/email');
//
<?xml version="1.0"?>
<address-book>
<person id="1">
<firstname>D</firstname>
<lastname>S</lastname>
<city>New York</city>
<state>NY</state>
<email>[email protected]</email>
</person>
<person id="2">
<firstname>A</firstname>
<lastname>T</lastname>
<city>San Francisco</city>
<state>CA</state>
<email>[email protected]</email>
</person>
</address-book>
|
|
|
|
| Related examples in the same category |
|