开发者

Help me to parse

I'm using a class written by a blogger that takes an XML string and spits out a NSDictionary.

It's beautiful...works perfectly, but my tag is not parsed. since in that class he has used like below

NSString *const kXMLR开发者_高级运维eaderTextNodeKey = @"text";

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    // Update the parent dict with text info
    NSMutableDictionary *dictInProgress = [dictionaryStack lastObject];

    // Set the text property
    if ([textInProgress length] > 0)
    {
        [dictInProgress setObject:textInProgress forKey:kXMLReaderTextNodeKey];



        // Reset the text
        [textInProgress release];
        textInProgress = [[NSMutableString alloc] init];
    }

    // Pop the current dict
    [dictionaryStack removeLastObject]; }

Kindly please help me out how to fix this...

Thanks a lot


Note: Make sure the XML you’re parsing doesn’t contain a field named “text”! You can change it to a non-conflicting name by editing the kXMLReaderTextNodeKey constant at the top of XMLReader.m.

This is there in the BLOGGER Website. In XMLReader.m file you have NSString *const kXMLReaderTextNodeKey = @"text"; which conflicts with your xml tag <text> so either change your xml field tag from <text> to anything else or

change NSString *const kXMLReaderTextNodeKey = @"text";

to NSString *const kXMLReaderTextNodeKey = @"textdata";

After that use NSDictionary as routine code. Check it out and let me know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜