KissXML icon indicating copy to clipboard operation
KissXML copied to clipboard

how to use xpath to get xml nodes(the xml includes namespace)

Open sakura0720 opened this issue 13 years ago • 0 comments

When I use xpath to get xml nodes as below, it returns 0 objects. I know the reason is xml's namespace. But I don't know how to solve this problem with KissXML.

ps: I use "[]" to replace "<>" because of the github editor can't display them rightly.

XML: [?xml version="1.0" encoding="utf-8"?] [soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"] [soap:Body] [HelloTestResponse xmlns="http://tempuri.org/"] [HelloTestResult>string</HelloTestResult]
[/HelloTestResponse] [/soap:Body] [/soap:Envelope]

KissXML method: DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:theXML options:0 error:nil]; NSArray *nodes = [doc nodesForXPath:@"//HelloTestResponse" error:nil];

The nodes' count is always 0;

sakura0720 avatar Jul 26 '12 02:07 sakura0720