user141302
user141302

Reputation:

how to identify that XML parsing has been finished?

how can i identify that XML parsing has been finished? any method is there to be called at the end of parsing all data?

Upvotes: 0

Views: 146

Answers (3)

peter.murray.rust
peter.murray.rust

Reputation: 38063

Most standard XML parsers either create a complete DOM or explicitly expose the SAX API (http://www.saxproject.org/quickstart.html). The SAX API has a specific endDocument() method after which you can assume that the document has been completely read. The DOM methods do not have a universal API but a typical example is given by XOM (http://www.xom.nu) with a call:

Document doc = new Builder().build(myInstream);

This either completes satisfactorily or throws an exception.

There are other tools such as StAX (http://stax.codehaus.org/Home) which allow partial parsing.

Upvotes: 0

Vladimir
Vladimir

Reputation: 170859

Assuming that you use NSXMLParser:

- (void)parserDidEndDocument:(NSXMLParser *)parser

Sent by the parser object to the delegate when it has successfully completed parsing.

Upvotes: 1

ennuikiller
ennuikiller

Reputation: 46965

Use this method and when you reach the enclosing end element process it accordingly

(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 

Upvotes: 0

Related Questions