views:

293

answers:

1

I am new to iphone development.I am parsing a xml page .The xml page concist of many elements inside the parant element < entry > .When parsing inside the NSXMLParser foundCharacters method i gave a print statement to print The "currentElement". It does not print all the elememts between the< entry > and tags.It just print only some 13 elements.But there are around 22 elements inside the entry tag.I found only the tags with closing tags are displayed as current elements in "found character" method.The element in the single tag like < category scheme="xxxxxxxxxxx"term="yyyyy" /> like "category" is not displayed. I want to append the value of scheme attribute to my current string.Please help me out.Thanks.

+3  A: 

If you want to access attributes of a tag you can do so by using the following:

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

    NSString *scheme = [attributeDict valueForKey:@"scheme"];

The found character method only scan for characters included between tags and does not scan for attributes.

Felix
Is there any way out in found character method
Warrior
I don't think so. It is also more convenient to use the above method as this passes all attributes directly into a dict. Just my 2cents
Felix