xml - How to select an attribute using nodesForXPath (NSXMLDocument) -


I want to select XML element using Xpath in an XML document.

My XML document is an example of NSXMLDCast. Here is an example of an XML document:

  & lt; Rootnode & gt; & Lt; Mynode myattrib = "getMe" & gt; & Lt; / Mynode & gt; & Lt; / Rootnode & gt;   

My XPath is something like this:

  // mynode @ myattrib   

this value is "getMe" according:).

When I try to:

  [xmlDoc nodesforx path: @ "// mynode @ myattrib" error: & amp; Error] ;   

I get the following error:

  NSLog (@ "% @", error);   

Output:

  XQueryError: 3 - "Invalid token (@) - // mynode @ myattrib" in line: 1   

What should I change to do this work? Is the @ symbol used in any other way?

Add the first slash @ as:

  // mynode / @ Myattrib    

Comments