GDataXML解析:
导入从网上下载的文件:GDataXMLNode.h GDataXMLNode.m
NSString *responseString = [[NSString alloc] initWithData:urlData encoding: NSUTF8StringEncoding];
GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:responseString options:0 error:nil];[responseString release];
GDataXMLElement *rootElement = [xmlDocument rootElement];
if ([rootElement elementsForName:@"diffgr:diffgram"] > 0){
GDataXMLElement *diffgramElement = [[rootElement elementsForName:@"diffgr:diffgram"] objectAtIndex:0];
if ([diffgramElement elementsForName:@"NewDataSet"] > 0)
{
GDataXMLElement *NewDataSetElement = [[diffgramElement elementsForName:@"NewDataSet"] objectAtIndex:0];
if ([NewDataSetElement elementsForName:@"ds"] > 0)
{
NSArray *dsArray = [NewDataSetElement elementsForName:@"ds"];
for(GDataXMLElement *dsInfo in dsArray)
{
Person *person = [[Person alloc] init];
person.name = [[[dsInfo elementsForName:@"name"] objectAtIndex:0] stringValue];
person.age = [[[[dsInfo elementsForName:@"age"] objectAtIndex:0] stringValue] intValue];
person.sex = [[[dsInfo elementsForName:@"sex"] objectAtIndex:0] stringValue];
[person release];
Flag = TRUE;
}
}
}
}
[xmlDocument release];