PHP xpath() Funksie
Voorbeeld
Voer 'n XPath-navraag op die XML-dokument uit:
<?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);
?>
Definisie en gebruik
Die xpath()-funksie voer 'n XPath-navraag op die XML-dokument uit.
Sintaksis
SimpleXMLElement::xpath(path)
Parameterwaardes
Parameter | Description |
---|---|
path | Required. Specifies an XPath path to use |
Tegniese besonderhede
Terugkeerwaarde: | 'n Reeks SimpleXMLElemente oor sukses. ONWAAR op mislukking |
---|---|
PHP weergawe: | 5,0+ |
❮ PHP SimpleXML-verwysing