Run an XPath query on the XML document:
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Do not forget me this weekend!</body>
</note>
XML;
$xml = new SimpleXMLElement($note);
$result = $xml->xpath("/note/to");
print_r($result);
?>
Run Example »
The xpath() function runs an XPath query on the XML document.
SimpleXMLElement::xpath(
path)
Parameter | Description |
---|---|
path | Required. Specifies an XPath path to use |
Return Value: | An array of SimpleXMLElements on success. FALSE on failure |
---|---|
PHP Version: | 5.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!