Ono è piuttosto semplice:
ONOXMLDocument *document = [ONOXMLDocument XMLDocumentWithData:data error:&error];
for (ONOXMLElement *element in document.rootElement.children) {
NSLog(@"%@: %@", element.tag, element.attributes);
}
Come GDataXMLDocument:
NSData* xmlData = [[NSMutableData alloc] initWithContentsOfURL:[NSURL URLWithString:link]];
GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:nil];
NSArray* entries = [document.rootElement elementsForName:@"entry"];
for(GDataXMLElement* element in entries)
{
published = [element elementsForName:@"published"][0];
}
o NSXMLParser:
func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if elementName == "author" {
self.item.author = self.foundCharacters;
}
if elementName == "description" {
self.item.desc = self.foundCharacters;
}
if elementName == "item" {
let tempItem = Item();
tempItem.author = self.item.author;
tempItem.desc = self.item.desc;
tempItem.tag = self.item.tag;
self.items.append(tempItem);
self.item.tag.removeAll();
}
self.foundCharacters = ""
}
Riferimenti