mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-27 02:12:19 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@187152 c90b9560-bf6c-de11-be94-00142212c4b1
106 lines
2.9 KiB
XML
106 lines
2.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.13 $ -->
|
|
<!-- EN-Revision: 1.9 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry id='function.simplexml-load-string'>
|
|
<refnamediv>
|
|
<refname>simplexml_load_string</refname>
|
|
<refpurpose>Convertit une chaîne XML en objet</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>object</type><methodname>simplexml_load_string</methodname>
|
|
<methodparam><type>string</type><parameter>data</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_string</function> convertit la chaîne XML
|
|
<parameter>data</parameter> et retourne un objet de la classe
|
|
<type>SimpleXMLElement</type> possédant des propriétés contenant les données
|
|
de la chaîne.
|
|
En cas d'erreur, cette fonction retourne &false;.
|
|
</para>
|
|
<para>
|
|
Vous pouvez utiliser le paramètre optionnel <parameter>class_name</parameter> et, ainsi,
|
|
la fonction <function>simplexml_load_string</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>
|
|
<para>
|
|
<example>
|
|
<title>Convertir une chaîne XML</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$string = <<<XML
|
|
<?xml version='1.0'?>
|
|
<document>
|
|
<title>Forty What?</title>
|
|
<from>Joe</from>
|
|
<to>Jane</to>
|
|
<body>
|
|
I know that's the answer -- but what's the question?
|
|
</body>
|
|
</document>
|
|
XML;
|
|
|
|
$xml = simplexml_load_string($string);
|
|
|
|
var_dump($xml);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
SimpleXMLElement Object
|
|
(
|
|
[title] => Forty What?
|
|
[from] => Joe
|
|
[to] => Jane
|
|
[body] =>
|
|
I know that's the answer -- but what's the question?
|
|
)
|
|
]]>
|
|
</screen>
|
|
<simpara>
|
|
A partir de là, vous pouvez utiliser <literal>$xml->body</literal>
|
|
et tout autre élément.
|
|
</simpara>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>simplexml_load_file</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
|
|
-->
|