/ Published in: Objective C
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
- (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"); }