Re: Parsing XML from a string
Re: Parsing XML from a string
- Subject: Re: Parsing XML from a string
- From: Marcel Borsten <email@hidden>
- Date: Wed, 24 Oct 2007 01:14:02 +0200
I tried your suggestions and they worked like a charm, thanks guys!
Marcel
Op 23 okt 2007, om 23:40 heeft Jim Murry het volgende geschreven:
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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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