开发者

XMLReader : get attributes value from NSDictionary

I'm using the XMLReader class from http://troybrant.net/blog/,

it parsea an xml into an NSDictionary, for example :

NSString *myxml=@"< students od=\"ii\">< student>< name>Raju< /name>< age>25< /age>< address>abcd< /address>< /student>< /students>";
NSDictionary *dict = [XMLReader dictionaryForXMLString:myxml error:nil];

gives me an NSDictionary like:

students = 
{
    "@od" = ii;
    student = 
    {
        address = abcd;
        age = 25;
        n开发者_Go百科ame = Raju;
    };
};

I can perfectly extract any of these parameters except for the attributes. Can someone tell me how to get the value of 'od'?

Thanks.

EDIT : i resolved th problem,actually i had to create a new NSDictionary :

NSDictionary *str = [students valueForKey:@"@od"];


Why not use NSXMLParser? The delegate method returns an NSDictionary full of the attributes in - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict


EDIT : i resolved th problem,actually i had to create a new NSDictionary :

NSDictionary *str = [students valueForKey:@"@od"];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜