I'm developing a website and I need to load an xml file- let's say test.xml
XML nodes are well-formated, but values inside of them aren't. Value of every node is CDATA nested string (but CDATA isn't always well-formated). Example:
<root>
<data>
<value1><![CDATA[Some value]]></value1>
<value2><![CDATA[ ]]></value2>
<value3>![CDATA[ ]]></value3>
</data>
</root>
Original XML structure is more complex, but this is the example of CDATA usage. In node value3, CDATA isn't valid (missing '<' character before '![CDATA').
I've tried to load the file with following code
<?php
$xml = simplexml_load_file("test.xml");
?>
but I was getting warnings.
Then I've tried to use LIBXML_NOCDATA, but it wasn't improved. The second code I've tried was:
<?php
$xml = simplexml_load_file("test.xml", null, LIBXML_NOCDATA);
//$xml = simplexml_load_file("test.xml", 'SimpleXMLElement', LIBXML_NOCDATA);
?>
but still with warnings (with both lines).
Is it possible to load file and then parse it (e.g $xml->data->value3) or not?