Reputation: 33
I am developing an iPad app on Xcode 4.2 for iOS 5.
In some cases in my app I need to do a sync call to a web service. So I get a SOAP response synchronously, which I need to parse to get the result.
I cannot use the event-driven XML parser NSXMLParser
, since I need to return a sync result. Given that I cannot use NSXMLDocument
on iOS, I am searching the SOAP response for the CallMethodResult
and /CallMethodResult
tags. The text between these tags is the result I need.
But if that result should be Tom & Jerry
, the result in the XML is Tom & amp; Jerry
. If I could use a nice XML document parser it would handle conversion of & amp;
for me. I can do search and replaces to fix the resulting string, of course, but I hope I don't have to reinvent the wheel.
My result may contain any number of XML-unfriendly characters that would be fixed by an XML parser, so my conversion code could get quite long.
What's the best way to extract node info from XML without going down the event-driven route?
Upvotes: 0
Views: 1289
Reputation: 16337
I cannot use the event-driven XML parser NSXMLParser, since I need to return a sync result
By 'sync', do you mean synchronous?
If so, you can still use NSXMLParser
. Despite being event-driven, it is synchronous. The - (BOOL)parse
method does not return until the parsing is complete.
Upvotes: 4