| 
	
 | 
 Posted by mandric on 08/07/06 22:53 
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 
http://us3.php.net/manual/en/function.simplexml-load-string.php 
 
  $xml = simplexml_load_string($newsMLString, 'SimpleXMLElement', 
LIBXML_NOCDATA); 
  echo $xml->asXML(); 
 
  $xml = simplexml_load_string($newsMLString); 
  echo $xml->asXML(); 
 
  $xml = simplexml_load_file('include/newsMLSpecs.xml'); 
  echo $xml->asXML(); 
 
  $xml = simplexml_load_file('include/newsMLSpecs.xml', 
'SimpleXMLElement', 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: 
http://public.yahoo.com/~ron/news/specs.xml 
 
Any ideas? 
 
Thanks! 
 
Milan
 
  
Navigation:
[Reply to this message] 
 |