Parsing XML in PHP with XMLReader - mixed content element - where'd my text go?

I'm having trouble parsing out a piece of plain text; even looping over all nodes with a print-statement, none of them contain the text I wrote in the XML file.

Here's the element specification from the DTD:

<!ELEMENT question (#PCDATA | choice)*>

And here's the data I'm using:

<question id="porridge" name="porridge" type="multiple">
 What is 1 + 2?
 <choice id="twelve" value="twelve">12</choice>
 <choice id="three" value="three" correct="true">3</choice>
 <choice id="banana" value="banana">Banana!</choice>
</question>

The first node in the <question> is of type XMLReader::TEXT, but it's empty according to readOuterXML(). How can I get at the "What is 1 + 2?"

Answers


readOuterXML() moves the current node around and doesn't return the actual contents of the node in all cases. My test loop was breaking the rest of the parsing.


Need Your Help

mysql table multi foreign key cascade

mysql sql jpa foreign-keys cascade

Let's say I have 4 tables related as below diagram

export to excel datagrid adobe flex3

actionscript-3 apache-flex flex3

I found the following code here only I kept the same in my Adobe Flex project but after clicking on the export to Excel button I can't see any Excel opening in addition to that my datagrid is filling