Files
doc-fr/reference/simplexml/functions/simplexml-element-xpath.xml
David Manusset 7d7d7afdb2 typo
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@187045 c90b9560-bf6c-de11-be94-00142212c4b1
2005-05-26 21:18:03 +00:00

95 lines
2.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<refentry id='function.simplexml-element-xpath'>
<refnamediv>
<refname>SimpleXMLElement->xpath</refname>
<refpurpose>Exécute une requête Xpath sur des données XML</refpurpose>
</refnamediv>
<refsect1>
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>SimpleXMLElement->xpath</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
</methodsynopsis>
<para>
La méthode <literal>xpath</literal> cherche dans la node SimpleXML des
enfants qui correspondent au <parameter>path</parameter>
<acronym>Xpath</acronym>.
Elle retourne toujours un tableau d'objets <type>array</type> SimpleXMLElement.
</para>
<para>
<example>
<title>Xpath</title>
<programlisting role="php">
<![CDATA[
<?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";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
/a/b/c: text
/a/b/c: stuff
b/c: text
b/c: stuff
]]>
</screen>
<simpara>
Notez que les deux résultats sont égaux.
</simpara>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->