1

IOS 使用 NSXMLParser 获取 XML 属性

嗨,大家好,

我有一个如下所示的 XML:

<Rows>
<RowOne SKATERID="706" MANUFACTURER="A-DZG" ISFACT="F" ISSKATE="F"> True</RowOne>
<RowTwo SKATERID="318" MANUFACTURER="A-FGW" ISFACT="F" ISSKATE="T"/> True</RowTwo>
<RowThree SKATERID="458" MANUFACTURER="A-OPJ" ISFACT="F" ISSKATE="T"/> False</RowThree>
<RowThree SKATERID="178" MANUFACTURER="A-JSL" ISFACT="F" ISSKATE="T"/> True</RowThree>
.
.
.
</Rows>

你们中的任何人都知道如何获取每个节点的属性,例如 SKATERID,MANUFACTURER,ISFACT,ISSKATE 吗?

我会非常感谢你的帮助

4

1 回答 1

0

使用 NSXMLParserDelegate 你想在 didStartElement 中获取属性

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
  NSString *SKATERID = [attributeDict objectForKey:@"SKATERID"];
  NSString *MANUFACTURER = [attributeDict objectForKey:@"MANUFACTURER"];
  .
  .
  .
}
于 2013-06-24T22:55:58.957 回答