Fonction PHP xpath()
Exemple
Exécutez une requête XPath sur le document XML :
<?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);
?>
Définition et utilisation
La fonction xpath() exécute une requête XPath sur le document XML.
Syntaxe
SimpleXMLElement::xpath(path)
Valeurs des paramètres
Parameter | Description |
---|---|
path | Required. Specifies an XPath path to use |
Détails techniques
Valeur de retour : | Un tableau de SimpleXMLElements en cas de succès. FAUX en cas d'échec |
---|---|
Version PHP : | 5.0+ |
❮ Référence PHP SimpleXML