wireapp/Ono

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

Homepage:

Size: 218

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ono (?)

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.

Features
Installation

CocoaPods is the recommended method of installing Ono. Simply add the following line to your Podfile:

Podfile
'Ono'
Usage
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);

Demo

Build and run the example project in Xcode to see Ono in action.

Requirements

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.

Contact

Mattt Thompson @mattt

License

Ono is available under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.