tags:

views:

7

answers:

1

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?"

A: 

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.

Geofrey Sanders