I want to validate the string value after getting in the below parser delegate method
I have tried like [string length]>0 ,(string !=NULL) in if condition still blank string is printed in the NSlog.So what is the efficient method to validate the sting.I have used the below code.
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([elemName isEqualToString:@"productName"]) {
if (!prodStringValue) {
prodStringValue = [[NSMutableString alloc] initWithCapacity:50];
}
[prodStringValue appendString:string];
if(prodStringValue && [prodStringValue length]>0 && (prodStringValue !=NULL))
{
prodNameStr = prodStringValue;
NSLog(@"productName:%@",prodNameStr);
}
if(string && [string length]>0 && (string !=NULL))
{
prodNameStr = string;
NSLog(@"productName:%@",string);
}
}
}
you can try this below few lines of code