NSXMLParser didEndElement和didStartElement未被调用

时间:2016-02-16 08:19:44

标签: objective-c parsing nsmutablearray nsxmlparser saxparser

我想解析我的iPhone应用程序的以下信息,但它无法正常工作

<account>
  <account_list type="required">
          <test_account value="ABCD" />
  </account_list>
</account>

#define kAccount @"account"
#define kAccountList @"account_list"
#define kTestAccount @"test_account"
#define kAttValue @"value"
#define kAttType @"type"

这是&#34; didStartElement&#34;

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName  namespaceURI:(NSString *)namespaceURI 
qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{   


else if([elementName isEqualToString:kAccountList])
{
    if([[_elemsStack head] isEqualToString:kAccount])
    {
        _currentTestAccount = [[NSMutableArray alloc] init];
        NSString* type = [attributeDict valueForKey:kAttrType];
        [_currentTestAccount addObject:type];
    }
}
else if([elementName isEqualToString:kTestAccount])
{
    if([[_elemsStack head] isEqualToString:kAccountList])
    {
        NSString* value = [attributeDict valueForKey:kAttValue];
        [_currentTestAccount addObject:value];
    }
}

这是&#34; didFinishElement&#34;

else if ([elementName isEqualToString:kAccountList])
    {
        if ([_elemsStack startsWith:kAccount, nil])
        {
        if (_currentTestAccount != nil)
        {
            _currentData._currentTestAccount = _currentTestAccount;
            _currentTestAccount = nil;
        }
    }
}

感谢有关此实施的任何帮助, 提前致谢

0 个答案:

没有答案