Reputation: 2941
I would like to parse an XML tag that looks something like this:
<image href="..."/>
I'm currently using BlockRSSParser
to do it.
I've tried to do it in the following method:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
// String is empty:
}
What is the correct way to parse XML like this using XMLParser
?
Upvotes: 0
Views: 71
Reputation: 318944
You get attribute values in the parser:didStartElement:namespaceURI:qualifiedName:attributes:
method:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"image"]) {
NSString *href = attributes[@"href"];
}
}
Upvotes: 2