Reputation: 2801
I'd like to select the attribute from an XML element within an XML document using XPath.
My XML document is an instance of NSXMLDocument. Here is an example of the XML Document:
<rootnode>
<mynode myattrib="getMe"></mynode>
</rootnode>
My XPath is something like:
//mynode@myattrib
This should return the value "getMe" (according to: http://www.bit-101.com/xpath/ ).
When I try to do this using:
[xmlDoc nodesForXpath:@"//mynode@myattrib" error:&error];
I get the following in error:
NSLog(@"%@",error);
Output:
XQueryError:3 - "invalid token (@) - //mynode@myattrib" at line:1
What should I change to get this to work? Is the @
symbol used in some other way?
Upvotes: 3
Views: 2766