这是下面的代码,我需要在 iOS 中使用 GDataXml 解析部分和公司子数据。
-<MainList>
<FirstMessage>Right</FirstMessage>
<SecondMessage>Wrong</SecondMessage>
<Status>0</Status>
-<CompanyList>
-<Company>
<Address1>12447 Hedges Run Drive</Address1>
<Address2>#B-1 </Address2>
<City>Lake Ridge</City>
<CompanyName>Starbucks</CompanyName>
<CreatedBy>example@example.com</CreatedBy>
-</Company>
-<Company>
<Address1>12447 Hedges Run Drive</Address1>
<Address2>#B-1 </Address2>
<City>Lake Ridge</City>
<CompanyName>Starbucks</CompanyName>
<CreatedBy>example@example.com</CreatedBy>
-</Company>
</CompanyList>
</MainList>
这是我的尝试,我一切都很好,但我在 NSArray arr 中一无所获。
NSArray *channels = [rootElement elementsForName:@"CompanyList"];
for (GDataXMLElement *icon in channels) {
NSArray *arr = [icon elementsForName:@"Company"];
if ([arr count]>0)
{
NSlog(@"Done");
}
}