I’m reading a XML file and parsing it using Obj-C and cocoa. I am reading the values using the following line (to read the <DocOwner> tag):
NSArray* DocownerArray = [root nodesForXPath:@"//DocOwner" error:nil];
for(NSXMLElement* xmlElement in DocownerArray)
[DocOwner addObject:[xmlElement stringValue]];
but I ran into a problem, in cases where I have the following:
<Discover id="1234">SomeValue</Discover>
using the previous method will return SomeValue but no the id=1234. How can I parse that part?
This is done on XCode 4 for Mac OS X.
Thank you
Have you tried NSXMLElement’s attributeForName method like
and get the stringValue from the returning NSXMLNode?