views:

24

answers:

1

Hello everybody,

Im using libxml2 on the iPhone with the nice Method: PerformXMLXPathQuery from Cocoa with Love. The problem is how to find out witch xml got sent without first parsing the whole document... I tried to use the @"/" query to retrieve the first element as written on the introduction of Cocoa with Love but unfortunately, the PerformXMLXPathQuery crashes cause of this query!

When I use the @"/*" command the whole tree gets parsed, which is very inefficient in terms of time and memory consumption..

Any Ideas how this works?

Thanks Markus

A: 

I'm not sure how tight your performance requirements are, but using a SAX parser, such as NSXMLParser, would enable you to quit parsing after you processed the element you're looking for. See the

- (void)abortParsing

method on the parser, and

– parser:didStartElement:namespaceURI:qualifiedName:attributes:
– parser:didEndElement:namespaceURI:qualifiedName:

on the NSXMLParserDelegate protocol.

TyB
Thanks for your hint, I tested the NSXMLParser but it is to slow for my requirements. I solved the problem by testing the request url witch tells me how the xml file will look like.
Markus