HelenaM
HelenaM

Reputation: 1855

NSXMLParser stops parsing when it finds comments in the XML file

I'm parsing XML using an NSXMLParser, but when finds comments like this:

<!-- ------------------------------------------- -->
<!--           This is a comment             -->

The parser stops parsing. Does anyone know why this happens?

Upvotes: 0

Views: 196

Answers (1)

Undo
Undo

Reputation: 25697

According to the NSXMLParser docs,

An NSXMLParser notifies its delegate about the items (elements, attributes, CDATA blocks, comments, and so on) that it encounters as it processes an XML document. It does not itself do anything with those parsed items except report them. It also reports parsing errors.

Therefore, you probably need to implement the delegate (protocol reference here) to catch these notifications:

- (void)parser:(NSXMLParser *)parser foundComment:(NSString *)comment

Upvotes: 1

Related Questions