Je dois sauvegarder la balise <![CDATA[]]>
lorsque j'analyse un document XML.SimpleXML: gérer la présence de balises CDATA dans la valeur de nœud
Par exemple, j'ai noeud:
<Dest><![CDATA[some text...]]></Dest>
Dans le fichier xml peut être présent sans nœuds CDATA.
Puis-je traiter tous les nœuds en boucle:
$dom = simplexml_load_file($path);
foreach($dom->children() as $child) {
$nodeValue = (string) $child;
}
En conséquence, quand je processus noeud dans l'exemple ci-dessus - $nodeValue
= some text...
Mais j'ai besoin $nodeValue
= <![CDATA[some text...]]>
Il est un moyen de le faire?
exemple du fichier:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Params>
<param>text</param>
<anotherParam>text</anotherParam>
</Params>
<Content>
<String>
<Source>some another text</Source>
<Dest>some another text 2</Dest>
</String>
<String>
<Source>some another text 3</Source>
<Dest><![CDATA[some text...]]></Dest>
</String>
</Content>
</Root>
Pouvez-vous donner un exemple de fichier XML? –