0

我正在做 xml 解析,其中获取 Web 服务响应

http://layzrd.gets-it.net:8889/ProfilePage.aspx?currentuserid=6&userid=6

现在在解析中,我需要将 currentuserid 与 userid 匹配,如果两者都匹配并且某些条件将被执行。我正在做 xml 解析,请有人告诉我如何匹配这个字符串。

4

2 回答 2

1

使用TBXML解析,非常好用。可能是它的工作

TBXML * tbxml = [[TBXML alloc] initWithURL:apiURL];
    if(tbxml)
    {

        TBXMLElement * root = tbxml.rootXMLElement; 

        if (root) 
        {  
            NSString * replyCode = [TBXML valueOfAttributeNamed:@"replyCode" forElement:root];

            if ([replyCode isEqualToString:@"success"])
            {
                TBXMLElement * Notifications    = [TBXML childElementNamed:@"Notifications" parentElement:root];
                TBXMLElement * Notification = [TBXML childElementNamed:@"Notification" parentElement:Notifications];
                while (Notification != nil) 
                {

                    NSString *idOfMessage = [TBXML valueOfAttributeNamed:@"id" forElement:Notification];
                    NSString *storeName = [TBXML valueOfAttributeNamed:@"storeName" forElement:Notification];
}}}}
于 2012-04-12T07:03:57.207 回答
0
if ([string1 isEqualToString:string2])
{

    //Strings compared do ur operations here
    /* returs yes (1) if both strings are equal else retur no (0)


}
于 2012-04-12T10:36:32.150 回答