Skip to content

Instantly share code, notes, and snippets.

@davidfmiller
Created May 17, 2017 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfmiller/1d3d6b07dafcd8e3b0f782325606f9a9 to your computer and use it in GitHub Desktop.
Save davidfmiller/1d3d6b07dafcd8e3b0f782325606f9a9 to your computer and use it in GitHub Desktop.
NSXMLNode+StringForXPath
#import "NSXMLNode+StringForXPath.h"
@implementation NSXMLNode (StringForXPath)
- (NSString *) stringForXPath:(NSString*)xpath
{
NSError *error;
NSArray *nodes = [self nodesForXPath:xpath error:&error];
if (error || nodes.count == 0)
{
return nil;
}
return [[nodes objectAtIndex:0] stringValue];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment