simplexml_load_string
(PHP 5)
simplexml_load_string --
Convertit un chaîne XML en objet.
Description
object SimpleXMLElement
simplexml_load_string ( string data)
simplexml_load_string() convertit la chaîne XML
data
en objet possédant des propriétés contenant les données de la chaîne.
En cas d'erreurs, cette fonction retourne FALSE.
Exemple 1. Convertir une chaîne XML
<?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); ?>
|
L'exemple ci-dessus va afficher : SimpleXMLElement Object
(
[title] => Forty What?
[from] => Joe
[to] => Jane
[body] =>
I know that's the answer -- but what's the question?
) |
A partir de là, vous pouvez utiliser $xml->body
et tout autre élément.
|
Voir aussi
simplexml_load_file().