<?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML;
$xml = simplexml_load_string($string);
/* On cherche <a><b><c> */ $result = $xml->xpath('/a/b/c');
while(list( , $node) = each($result)) { echo '/a/b/c: ',$node,"\n"; }
/* Les chemins relatifs fonctionnent aussi... */ $result = $xml->xpath('b/c');
while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; } ?>
|