Re: Parsing XML from a string
Re: Parsing XML from a string
- Subject: Re: Parsing XML from a string
- From: Jim Murry <email@hidden>
- Date: Tue, 23 Oct 2007 14:40:57 -0700
Just pass your string to this using dataUsingEncoding
- (void)deconstructXMLResponse:(NSData *)data
{
NSError *error;
NSXMLDocument *responseXML = [[NSXMLDocument alloc]
initWithData:data options:nil error:&error];
if (!responseXML)
{
NSLog(@"Error reading response: %@", error);
return;
}
NSLog(@"Response received: \n%@", responseXML);
[currentRecord setResponseRaw:[[NSString alloc] initWithData:data
encoding:NSASCIIStringEncoding]];
// Get a reference to the root node
NSXMLNode *rootNode = [responseXML rootElement];
if (rootNode == nil)
{
NSLog(@"error: rootNode == nil");
return;
}
else
{
NSString* tempString = [[rootNode childNamed:@"r_ONE"] stringValue];
[currentRecord setResponseONE:tempString];
}
}
On Oct 23, 2007, at 2:22 PM, Marcel Borsten wrote:
I'm using NSTask to wrap an application, this application gives
back XML. Can anybody sent me in the right direction in parsing the
XML-response and using the elements? Do I use NSXMLParser? But this
only seems to work with the contents of an URL or file. Is there a
way parse XML from a string object?
Marcel_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden