Name: Ono
Owner: Wire Swiss GmbH
Description: A sensible way to deal with XML & HTML for iOS & OS X
Forked from: wearezeta/Ono
Created: 2016-07-22 07:28:15.0
Updated: 2017-10-08 20:29:03.0
Pushed: 2017-04-03 08:41:17.0
Size: 218
Language: Objective-C
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A sensible way to deal with XML & HTML for iOS & Mac OS X
XML support in Cocoa isn't great (unless, of course, the XML in question is a .plist
). NSXMLParser
forces a cumbersome delegate model, which is extremely inconvenient to implement. NSXMLDocument
is a bit nicer to use, but only works on Mac OS X, and has a large memory footprint.
Ono makes working with XML & HTML as nice as JSON.
Whether your app needs to interface with a XML-RPC webservice, scrape a website, or parse an RSS feed, Ono will make your day a whole lot less terrible.
Ono (?) means “axe”, in homage to Nokogiri (?), which means “saw”.
Using AFNetworking? Easily integrate Ono into your networking stack with AFOnoResponseSerializer.
NSFastEnumeration
libxml2
NSString
or NSData
CocoaPods is the recommended method of installing Ono. Simply add the following line to your Podfile
:
'Ono'
ort "Ono.h"
ta *data = ...;
ror *error;
MLDocument *document = [ONOXMLDocument XMLDocumentWithData:data error:&error];
(ONOXMLElement *element in document.rootElement.children) {
NSLog(@"%@: %@", element.tag, element.attributes);
upport for Namespaces
ring *author = [[document.rootElement firstChildWithTag:@"creator" inNamespace:@"dc"] stringValue];
utomatic Conversion for Number & Date Values
te *date = [[document.rootElement firstChildWithTag:@"created_at"] dateValue]; // ISO 8601 Timestamp
teger numberOfWords = [[[document.rootElement firstChildWithTag:@"word_count"] numberValue] integerValue];
isPublished = [[[document.rootElement firstChildWithTag:@"is_published"] numberValue] boolValue];
onvenient Accessors for Attributes
ring *unit = [document.rootElement firstChildWithTag:@"Length"][@"unit"];
ctionary *authorAttributes = [[document.rootElement firstChildWithTag:@"author"] attributes];
upport for XPath & CSS Queries
ument enumerateElementsWithXPath:@"//Content" usingBlock:^(ONOXMLElement *element, NSUInteger idx, BOOL *stop) {
NSLog(@"%@", element);
Build and run the example project in Xcode to see Ono
in action.
Ono is compatible with iOS 5 and higher, as well as Mac OS X 10.7 and higher. It requires the libxml2
library, which is included automatically when installed with CocoaPods, or can be added manually by adding “libxml2.dylib” to the target's “Link Binary With Libraries” build phase.
Ono is available under the MIT license. See the LICENSE file for more info.