TouchXML Quick Guide

This is a Objective-C snippet, talking about TouchXML, CXMLDocument, parser and XML

TouchXML Quick Guide Add to Favorite

- (void)viewDidLoad {
        [super viewDidLoad];
	NSLog(@"Begin TouchXML Tutorial Code");
	
	// This is the TouchXML XMLDocument class.  We're going to initialize it with our publicTimelineUrl URL from above.
       CXMLDocument *xmlParser = [[[CXMLDocument alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.xml"] options:0 error:nil] autorelease];
	/* Here we use XPath to create an NSArray of usernames */
	NSArray *twitterUsernames = [xmlParser nodesForXPath:@"/statuses/status/user/screen_name" error:nil];
	
	// Loop through them and print
	for (CXMLElement *username in twitterUsernames) {
		NSLog(@"username = %@", [username stringValue]);
        }
	
	NSLog(@"End TouchXML Tutorial Code");
}

TouchXML Tutorial Code

Created by ThePeppersStudio (41 days, 8.44 hours ago)

Do you want to leave a message? Please login first.