PHP xpath() Fonction

❮ Référence PHP SimpleXML

Exemple

Exécutez une requête XPath sur le document XML :

<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Rappel</heading>
<body>N'oubliez pas de me rappeler ce week-end !</body>
</note>
XML;

$xml = new SimpleXMLElement($note);

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

print_r($result);
?>
Exécuter l'exemple »

Définition et Utilisation

La fonction xpath() exécute une requête XPath sur le document XML.


Syntaxe

SimpleXMLElement::xpath( chemin )

Valeurs des Paramètres

Paramètre Description
chemin Requis. Spécifie un chemin XPath à utiliser

Détails Techniques

Valeur de Retour : Un tableau de SimpleXMLElements en cas de succès. FALSE en cas d'échec
Version PHP : 5.0+

❮ Référence PHP SimpleXML