Created
July 20, 2012 07:49
-
-
Save Eric-Bro/3149363 to your computer and use it in GitHub Desktop.
TBXML usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableARRAY *main_array = [[NSMutableArray alloc]init]; | |
TBXML * tbxml = [[TBXML tbxmlWithURL: | |
[NSURL URLWithString: @"http://www.w3schools.com/xml/plant_catalog.xml"]] retain]; | |
TBXMLElement *root = tbxml.rootXMLElement; | |
if (root) { | |
TBXMLElement *current_element = [TBXML childElementNamed: @"PLANT" | |
parentElement: root]; | |
while (current_element != nil) { | |
TBXMLElement *entry = [TBXML childElementNamed: @"BOTANICAL" | |
parentElement: current_element]; | |
NSString *name = [TBXML textForElement: entry]; | |
[main_array addObject: name]; | |
current_element = current_element->nextSibling; | |
} | |
} | |
NSLog(@"%@", main_array); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment