I am using codeigniter framework, I have a xml file with below code:
<rss xmlns:content="" xmlns:wfw="" xmlns:dc="" xmlns:atom="" xmlns:sy="" xmlns:slash="" version="2.0"> <channel> <item> <title>Title1</title> <link>Link</link> <pubDate>Date</pubDate> <content:encoded> <![CDATA[ This is description 1 ]]> <![CDATA[ This is description 2 ]]> </content:encoded> </item> <item> <title>Title2</title> <link>Link2</link> <pubDate>Date2</pubDate> <content:encoded> <![CDATA[ This is description 3 ]]> <![CDATA[ This is description 4 ]]> </content:encoded> </item> </channel> </rss> I tried this to parse the xml:
<?php function test() { $xml = simplexml_load_file('http://localhost/testxml/testxml.xml','SimpleXMLElement',LIBXML_NOCDATA); echo "<pre>"; print_r($xml); echo "</pre>"; } ?> It is giving me output without the CDATA which is exists in this tag content:encoded:
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [item] => Array ( [0] => SimpleXMLElement Object ( [title] => Title1 [link] => Link [pubDate] => Date ) [1] => SimpleXMLElement Object ( [title] => Title2 [link] => Link2 [pubDate] => Date2 ) ) ) ) How can I get <content:encoded><![CDATA[ This is description 1 ]]><![CDATA[ This is description 2 ]]></content:encoded> this data in parsing?
No comments:
Post a Comment