Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing XML from a string



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Parsing XML from a string (From: Marcel Borsten <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.