0

I'm trying to parse an XML document using TouchXML for iOS. Normally this works great, but the current document I'm trying to parse contains angle brackets within the actual data. For example:

<reference>
<title>Title < 5</title>
</reference>

This fails due to an "invalid startTag" error. Is there anything I can do in TouchXML to get around this, or do I need to fix this in the source material?

Ben Williams
  • 4,695
  • 9
  • 47
  • 72
  • 1
    You at least *should* get it fixed in the source material, as this is invalid XML. Not knowing TouchXML, I can't say for certain whether a workaround is possible, but I doubt it. – Don Roby May 15 '12 at 22:41
  • Understand, and definitely agree. It's not my source material, but I agree this is the best option. – Ben Williams May 16 '12 at 05:37

1 Answers1

0

Not an ideal solution, but I ended up basically pre-processing the XML document before passing it to TouchXML. I used regular expressions to search for multiple angle brackets in a row (eg. <<, or <...<, or <...<...<), and replaced the additional ones with < or >. I then replaced these symbols with the original angle brackets when parsing the individual nodes for data.

There may be some way to tell TouchXML to ignore errors, but I couldn't find it.

Ben Williams
  • 4,695
  • 9
  • 47
  • 72