Hello,
Can someone please enlighten me on how to preserve the <![CDATA[]]>
element when parsing an xml file or string with simplexml. I'm using
libxml 2.6.16 and php 5.1.4.
I tried a few variations, I found at
$xml = simplexml_load_ string($newsMLS tring, 'SimpleXMLEleme nt',
LIBXML_NOCDATA) ;
echo $xml->asXML();
$xml = simplexml_load_ string($newsMLS tring);
echo $xml->asXML();
$xml = simplexml_load_ file('include/newsMLSpecs.xml ');
echo $xml->asXML();
$xml = simplexml_load_ file('include/newsMLSpecs.xml ',
'SimpleXMLEleme nt', LIBXML_NOCDATA) ;
echo $xml->asXML();
In all cases the CDATA element is stripped out. I don't understand why
an xml parser would do that by default? It could be my setup but not
sure.
I'm using the NewsML spec found here:
Any ideas?
Thanks!
Milan
Can someone please enlighten me on how to preserve the <![CDATA[]]>
element when parsing an xml file or string with simplexml. I'm using
libxml 2.6.16 and php 5.1.4.
I tried a few variations, I found at
$xml = simplexml_load_ string($newsMLS tring, 'SimpleXMLEleme nt',
LIBXML_NOCDATA) ;
echo $xml->asXML();
$xml = simplexml_load_ string($newsMLS tring);
echo $xml->asXML();
$xml = simplexml_load_ file('include/newsMLSpecs.xml ');
echo $xml->asXML();
$xml = simplexml_load_ file('include/newsMLSpecs.xml ',
'SimpleXMLEleme nt', LIBXML_NOCDATA) ;
echo $xml->asXML();
In all cases the CDATA element is stripped out. I don't understand why
an xml parser would do that by default? It could be my setup but not
sure.
I'm using the NewsML spec found here:
Any ideas?
Thanks!
Milan
Comment