PHP xpath()- Funktion
Beispiel
Führen Sie eine XPath-Abfrage für das XML-Dokument aus:
<?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);
?>
Definition und Verwendung
Die Funktion xpath() führt eine XPath-Abfrage für das XML-Dokument aus.
Syntax
SimpleXMLElement::xpath(path)
Parameterwerte
Parameter | Description |
---|---|
path | Required. Specifies an XPath path to use |
Technische Details
Rückgabewert: | Ein Array von SimpleXMLElements bei Erfolg. FALSE bei Fehler |
---|---|
PHP-Version: | 5.0+ |
❮ PHP-SimpleXML-Referenz