One of the things I need to do is parse XML and I didnt care for the NSXMLParser so I decided to use TouchXML for this. I downloaded the files from google code and included them in my xcode project then followed this tutorial. Next I decided to point the url to my local web server to test a webservice that returns a XML document. All fine and great but I was'nt sure how to get to any of my attributes, so here is how I did it:
//resultElement is a CXMLElement
//attributeForName is a method of CXMLElement which returns a CXMLNode
//stringValue is a method of CXMLNode that returns the string value for attribute by name
[[resultElement attributeForName:@"id"] stringValue];
Hopefully I will have time to post some more, but most of my time is spent developing but I do want to give back!!
Thanks, this is the only article where i found my answer.
ReplyDeletePretty good for a first post, this is exactly what I was googling for.
ReplyDeleteSame for me, first hit, perfect answer to my question, thanks alot
ReplyDeletePERFECT! Exactly what I needed. Amazing how a quick google search can have better documentation than the creators of TouchXML.
ReplyDeleteKeep it up.
Thank you so much :) I was searching for this for some time.
ReplyDeleteThis would get the attribute on the root element, however how do you get the attributes if they only exist on child nodes?
ReplyDeleteThanks man, you are a life saver!
ReplyDelete