iOS使用NSXMLParser获取XML属性

时间:2013-06-24 22:18:49

标签: ios nsxmlparser

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?

我真的很感谢你的帮助

1 个答案:

答案 0 :(得分: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"];
  .
  .
  .
}