如何在iPhone中查找或匹配NSString中的两个字符
我正在进行xml解析,其中获取web服务响应如何在iPhone中查找或匹配NSString中的两个字符,iphone,nsstring,Iphone,Nsstring,我正在进行xml解析,其中获取web服务响应 现在在解析中,我需要将currentuserid与userid匹配,如果两者都匹配并且将执行某些条件。我正在进行xml解析,请有人告诉我如何匹配此字符串。使用TBXML解析,它非常容易使用。可能有用吗 TBXML * tbxml = [[TBXML alloc] initWithURL:apiURL]; if(tbxml) { TBXMLElement * root = tbxml.rootXMLElement;
现在在解析中,我需要将currentuserid与userid匹配,如果两者都匹配并且将执行某些条件。我正在进行xml解析,请有人告诉我如何匹配此字符串。使用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];
}}}}
if ([string1 isEqualToString:string2])
{
//Strings compared do ur operations here
/* returs yes (1) if both strings are equal else retur no (0)
}