Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
November 10, 2009, 11:37 pm
rate this thread
i try to load a xml-file, but some part is always missing. This is an
extract of my file (it es well-formed!):
<d label="Company" marker="worker" period="always">
<![CDATA[This is the cdata part]]>
I load a xml file with:
$this->xmlData = simplexml_load_file('test.xml', NULL,
to get the cdata-content of nodes, this works pretty well. But i
cannot reach the attribute-values of the node.
When i load the file with:
$this->xmlData = simplexml_load_file('test.xml');
i get the atrribute-values, but not the cdata-content.
Is it possible to get the cdata-content and attributes at the same
Thanks in advance,
Re: simple_xml does not return attributes and cdata
Yes, use LIBXML_NOCDATA to get the CDATA. The attribute values of the nodes
are there, but you can't see them with var_dump or print_r.
(See http://bugs.php.net/bug.php?id=27517 which is marked invalid, but read
the comments. They say the cause is SimpleXML object overloading.)
In the case of your example, var_dump($this->xmlData->b->c->d) should show
you that the attributes are still there.