I've got a problem with parsing an XML file (nb. well formed one).
Consider XML file like this:
<?xml version="1.0" encoding="utf-8" ?> <root> <list> <item no="1"> <title>Item's 1 title</title> <content>Some long content with <special>tags</special> inside</content> </item> <item no="2"> <title>Item's 2 title</title> <content>Some long content with <special>tags</special> inside</content> </item> </list> </root> I need to get contents contents of each item in the list and put them in an array. Generally not a problem, but in this case, I can't get my head round it.
Problem lays in <content> contents. It is string with tags in-between. I can't find a way to extract the contents. SimpleXML returns/echoes just the string with anything including and inside <special> tags stripped out. Like this:
Some long content with inside. I'd ideally want it to get a string like this:
Some long content with <special>tags</special> inside How do I get it?
<content><![CDATA[Some long content with <special>tags</special> inside]]></content>which instructs parser not to parse content within CDATA tag (return it as is)