我有包含 xml 响应的字符串,(asmx Web 服务)我正在通过 APXML 库解析 xml。当我得到给我身体标签的根元素时,我不想要身体标签,我想获得根标签而不是子标签中的实际数据..请告诉我如何从中获取数据..谢谢..我的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>
<loginFunctionResponse xmlns="http://tempuri.org/">
<loginFunctionResult>
<Root xmlns="">
<child>
<id>52</id>
<name>mohsin</name>
</child>
</Root>
</loginFunctionResult>
</loginFunctionResponse>
</soap:Body>
</soap:Envelope>
我的代码是..
NSString *resultString=[[NSString alloc] initWithBytes:[resultData bytes] length:resultData.length encoding:NSUTF8StringEncoding];
NSLog(@"result string: %@",resultString);
APDocument *doc = [APDocument documentWithXMLString:resultString];
APElement *rootElement = [doc rootElement];
NSArray *childElement = [rootElement childElements];
for (APElement *chile in childElement) {
NSLog(@"chid name %@",chile.name);
NSLog(@"chile value %@",chile.value);
}
这给了我这个结果..
chid name soap:Body
chile value (null)