iostouchxml

Parsing documents including angle brackets using TouchXML on iOS


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?


Solution

  • 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.