mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-04-27 02:28:31 +02:00
6005d1159a
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@202670 c90b9560-bf6c-de11-be94-00142212c4b1
108 lines
3.3 KiB
XML
108 lines
3.3 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.16 $ -->
|
|
<!-- EN-Revision: 1.11 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry id='function.simplexml-load-file'>
|
|
<refnamediv>
|
|
<refname>simplexml_load_file</refname>
|
|
<refpurpose>Convertit un fichier XML en objet</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>object</type><methodname>simplexml_load_file</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>simplexml_load_file</function> convertit le document XML
|
|
<parameter>filename</parameter>
|
|
en un objet de type <type>SimpleXMLElement</type>.
|
|
Si une erreur survient lors de l'accès au fichier ou de son
|
|
interprétation, cette fonction retourne &false;.
|
|
</para>
|
|
<para>
|
|
Vous pouvez utiliser le paramètre optionnel <parameter>class_name</parameter> et ainsi,
|
|
la fonction <function>simplexml_load_file</function> retournera un objet de
|
|
la classe spécifiée. Cette classe doit étendre la classe
|
|
<type>SimpleXMLElement</type>.
|
|
</para>
|
|
<para>
|
|
Depuis &php; 5.1.0 et Libxml 2.6.0, vous pouvez aussi utiliser le paramètre
|
|
<parameter>options</parameter> pour spécifier des <link
|
|
linkend="libxml.constants">paramètres additionnels Libxml</link>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Libxml 2 supprime la protection des caractères des URI, alors si vous voulez
|
|
passer par exemple <literal>b&c</literal> comme paramètre URI à
|
|
<literal>a</literal>, vous devez appeler
|
|
<literal>simplexml_load_file(rawurlencode('http://example.com/?a=' .
|
|
urlencode('b&c')))</literal>. Depuis &php; 5.1.0, vous n'avez plus
|
|
besoin de faire cela puisque &php; le fait pour vous.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title>Interprétation d'un document XML</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Le fichier test.xml contient un document XML avec un élément racine
|
|
// et au moins un élément /[racine]/title.
|
|
|
|
if (file_exists('test.xml')) {
|
|
$xml = simplexml_load_file('test.xml');
|
|
|
|
var_dump($xml);
|
|
} else {
|
|
exit('Echec lors de l\'ouverture du fichier test.xml.');
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
SimpleXMLElement Object
|
|
(
|
|
[title] => Titre de l'exemple
|
|
...
|
|
)
|
|
]]>
|
|
</screen>
|
|
<simpara>
|
|
À partir de là, vous pouvez utiliser <literal>$xml->title</literal>
|
|
et tout autre élément.
|
|
</simpara>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>simplexml_load_string</function>.
|
|
</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
|
|
-->
|