simple_xml does not return attributes and cdata

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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 wrote:
Quoted text here. Click to load it

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 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.

Site Timeline