0

Hi I am working with the xml below is my xml from server.

 <message xmlns="jabber:client" to="91957@ip-148" id="A2EFL-1435" from="9176@ip-148"><x xmlns="jabber:x:event"><composing/><id>A2EFL-1434</id></x></message>

Now i need to check that whether xml having composing element or not.And I am not using any xml delegates. Is there any possibility with out using delegate methods for XML

 NSXMLElement *events = [message elementForName:@"x"];
    NSString *eventString=[[message elementForName:@"x"] stringValue];
    if (![eventString isEqualToString:@""]) {
        NSString *composingString=[[events elementForName:@"composing"] stringValue];
        if ([composingString isEqualToString:@""]||[composingString isEqualToString:@"nil"]) {}

But i need to check that xml tag not value

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Bittoo
  • 579
  • 7
  • 21

1 Answers1

0

You can just do it with string operations. Check for this.

NSRange rangeValue = [xmlString rangeOfString:@"<composing>" OR @"<composing/>" OR options:NSCaseInsensitiveSearch];

if (rangeValue.length > 0){

NSLog(@"Tag is present");

} 

else {

NSLog(@"Tag is not present");

}
Apurv
  • 17,116
  • 8
  • 51
  • 67