大家好我正在使用gdataxml库,正在使用示例文件:http://daniarnaout.com/School.xml
NSData *xmlData = [[NSMutableData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://daniarnaout.com/School.xml"]];
GDataXMLDocument *doc =[[GDataXMLDocument alloc] initWithData:xmlData options:0 error:nil];
NSArray *names =[doc nodesForXPath:@"//School/Student/Name" error:nil];
for(GDataXMLElement *name in names) { NSLog(@"name: %@ \n",name.stringValue); }
这很有效,但现在我想继续使用真实文档ftp://ftp2.bom.gov.au/anon/gen/fwo/IDV10753.xml
我可以使用NSLog(@"%@",doc.rootElement);
但如果我将xpath更改为//product/forecast/,
我没有得到任何东西。
基本上我想获取<area aac="VIC_PT025"
我做错了什么?
答案 0 :(得分:0)
为什么在这里使用nil
(错误)?
NSArray *names =[doc nodesForXPath:@"//School/Student/Name" error:nil];
您没有发现错误。对于第二个XML,您可能已经知道xpath存在问题。而不是//product/forecast/
,删除表达式末尾的额外/
;你需要//product/forecast
。