Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP xpath() Function

PHP xpath() Function


PHP SimpleXML Reference Manual 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

Tove

Jani

Reminder

Don't forget me this weekend!

PHP code

xpath("from"); print_r($result); ?>

The code above will output:

Array

(

[0] => SimpleXMLElement Object

(

[0] => Jani

)

)


PHP SimpleXML Reference Manual Complete PHP SimpleXML Reference Manual