Pretty straightforward — Is there any way to access the data of a processing instruction node using SimpleXML? I understand that SimpleXML is, well, simple; as a result it has a number of limitations, predominantly working with mixed content nodes.
An example:
Test.xml
<test>
<node>
<?php /* processing instructions */ ?>
</node>
</test>
Parse.php
$test = simplexml_load_file('Test.xml');
var_dump($test->node->php); // dumps as a SimpleXMLElement, so it's sorta found,
// however string casting and explicitly calling
// __toString() yields an empty string
So is this simply a technical limitation imposed by the simplicity of SimpleXML, or is there a way? I’ll transition to SAX or DOM if necessary, but the SimpleXML would be nice.
The problem is that < ? php ? > is considered a tag… so it gets parsed into a single big tag element. You’d need to do:
I’m not entirely sure this would work, but i think it will. Test it out…