PHP xpath() Function
Complete PHP SimpleXML Reference Manual
Definition and Usage
The xpath() function runs an XPath query against an XML document.
On success, this function returns an array of SimpleXMLElements objects. On failure, it returns FALSE.
Syntax
class SimpleXMLElement
{
string xpath(path)
}
| Parameters | Description |
|---|---|
| path | Required. Specifies the XPath path to search for in the XML document. |
Example
XML file
PHP code
xpath("from"); print_r($result); ?>The code above will output:
Array
(
[0] => SimpleXMLElement Object
(
[0] => Jani
)
)
Complete PHP SimpleXML Reference Manual