I'm trying to access the methodName element of an XML document using XPATH in Cocoa via the NSXMLElement object.
This is the XML representation of element
<iq type='set'
from='[email protected]/jrpc-client'
to='[email protected]/jrpc-server'
id='rpc1'>
<query xmlns='jabber:iq:rpc'>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value><i4>6</i4></value>
</param>
</params>
</methodCall>
</query>
</iq>
I've tried,
NSArray *nodes = [element nodesForXPath:@"iq/query/methodCall/methodName"
error:&err];
but it always returns an empty NSArray.
It works fine without the namespace.
Solution
/*[name()='iq']/*[name()='query' and namespace-uri()='jabber:iq:rpc']/*[name()='methodCall']/*[name()='methodName']