Re: How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:


Steve Mills
 

On Dec 11, 2019, at 12:21:27, Keary Suska <cocoa-dev@esoteritech.com> wrote:

IRC, NSXMLParser is pretty vanilla, and back in the day it was recommended to use an xml parsing library directly rather than NSXMLParser if you have to work with anything except basic XML. Does not seem like Apple has improved it since then. That being said, technically, there are only a small set of “standard” entities: &lt;, &gt;, &apos;, &quot; and &amp;. All other entities must be declared.

FWIW, the commonly accepted solution seems to be to pre-convert entities before passing passing to NSXMLParser. As long as the result is valid utf-8, it won’t choke the parser.

The most comprehensive discussion I could find was this one: https://stackoverflow.com/questions/2370842/resolving-html-entities-with-nsxmlparser-on-iphone which may or may not have an alternative solution.
Thanks for this. I ended up pre- and post-processing entities that aren't normally handled by the parser or the delegate in other places, because I simply want them to persist. Yeah, NSXMLParser and friends are pretty lame when it comes down to doing anything not involving elements and plain text.

--
Steve Mills
Drummer, Mac geek

Join cocoa@apple-dev.groups.io to automatically receive all group messages.