You are here: simplexml and CDATA « PHP Programming Language « IT news, forums, messages
simplexml and CDATA

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация