Can PHP Read "CData" Info?
Lets say that was reading an XML file and I wanted to pull and save to a variable the text only info in between these tags:
How would I go about doing that with PHP? Is it even possible?
<description><![CDATA[ some text, some text, and some text [...]]]></description>
Sure, I'd use SimpleXML:
The CDATA begin/end stuff isn't going to end up in $desc.
$x = simplexml_load_file ("content.xml");
$desc = $x->description;
You should be able to access it via the DOM classes, e.g.:
$xml = <<<EOD
<?xml version='1.0' ?>
<description><![CDATA[The first thing]]></description>
<description><![CDATA[The second thing]]></description>
$dom = new DOMDocument();
$descriptions = $dom->getElementsByTagName('description');
foreach($descriptions as $desc)
...alright..appreciate it...I just thought the "CDATA" stuff would get in the way...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)