Page 1 of 1

SimpleXML parse

Posted: Tue Nov 29, 2005 11:39 am
by jwalsh
I'm trying to parse an XML file similar to this...

Code: Select all

<RESULTS>
<TITLE> Name1 </TITLE>
<VALUE> Name1 Value </VALUE>
<TITLE> Name2 </TITLE>
<VALUE> Name2 Value </VALUE>
<TITLE> Name3 </TITLE>
<VALUE> Name3 Value </VALUE>
<TITLE> Name4 </TITLE>
<VALUE> Name4 Value </VALUE>
</RESULTS>
SimpleXML tells me to look first for the encapsulating tag as if it were formed like this...

Code: Select all

<RESULTS>
<ITEM>
<TITLE> Name1 </TITLE>
<VALUE> Name1 Value </VALUE>
</ITEM>
<ITEM>
<TITLE> Name2 </TITLE>
<VALUE> Name2 Value </VALUE>
</ITEM>
<ITEM>
<TITLE> Name3 </TITLE>
<VALUE> Name3 Value </VALUE>
</ITEM>
<ITEM>
<TITLE> Name4 </TITLE>
<VALUE> Name4 Value </VALUE>
</ITEM>
</RESULTS>
... which would be simple to parse, but that's not what I'm given. How can I parse the first example, even though it lacks the <ITEM> tag?

Thanks,

Josh

Posted: Tue Nov 29, 2005 3:40 pm
by jwalsh
I think I've gotten this figured out except that the xml is encoded with CDATA, so SimpleXML won't parse it... any suggestions on parsing CDATA??

Thanks,

Josh