我正在进行xml解析,其中获取Web服务响应
http://layzrd.gets-it.net:8889/ProfilePage.aspx?currentuserid=6&userid=6
现在在解析时我需要将currentuserid与userid匹配,如果两个匹配并且某些条件将被执行。我正在做xml解析,有人请告诉我如何匹配这个字符串。
答案 0 :(得分: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];
}}}}
答案 1 :(得分:0)
if ([string1 isEqualToString:string2])
{
//Strings compared do ur operations here
/* returs yes (1) if both strings are equal else retur no (0)
}