Current Location: Home> Function Categories> xpath

xpath

Run an XPath query on XML data.
Name:xpath
Category:Uncategorized
Programming Language:php
One-line Description:Run an XPath query on XML data.

Definition and usage

xpath() function runs an XPath query on an XML document.

Example

Run an XPath query on an XML document:

 <?php
$note = <<< XML
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Do not forget the meeting!</body>
</note>
XML ;

$xml = new SimpleXMLElement ( $note ) ;

$result = $xml -> xpath ( "/note/to" ) ;

print_r ( $result ) ;
?>

Run the instance

grammar

 SimpleXMLElement :: xpath ( path )
parameter describe
path Required. Specifies the XPath path to use.
Similar Functions
Popular Articles