如何使用TBXML解析SOAP响应?

时间:2013-03-26 06:02:24

标签: ios soap tbxml

大家好我想尝试使用TBXML解析XML SOAP响应,但我找不到根元素来进行解析。这是我的代码:

TBXML *tbxml =[TBXML tbxmlWithXMLString:theXML];
    TBXMLElement *root = tbxml.rootXMLElement;
     NSLog(@"root: %@",[TBXML elementName:root]);


    TBXMLElement *rootElement = [tbxml rootXMLElement];

    TBXMLElement *rootItemElem = [TBXML childElementNamed:@"item" parentElement:rootElement];

    if(root)
    {
        TBXMLElement *subcategoryEle = [TBXML childElementNamed:@"item" parentElement:root];
         NSLog(@"item: %@",[TBXML elementName:subcategoryEle]);
        while (subcategoryEle)
        {
            TBXMLElement * price = [TBXML childElementNamed:@"price" parentElement:subcategoryEle];
            TBXMLElement *color = [TBXML childElementNamed:@"color" parentElement:subcategoryEle];
            TBXMLElement * rating = [TBXML childElementNamed:@"rating" parentElement:subcategoryEle];


            NSString *color = [NSString stringWithCString:[[TBXML color] cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];

            NSLog(@"colorstr %@",color);
        }
    }

我遇到的问题是它没有进入WHILE循环。有什么建议吗?

0 个答案:

没有答案