XML/HTML 解析库 Ono

码农软件 · 软件分类 · HTML解析器 · 2019-04-02 18:11:47

软件介绍

Ono (斧)是 iOS & Mac OSX 处理  XML & HTML 的一种明智的方法(解析库)。

XML 在 Cocoa 的支持并不好,NSXMLParser 强制要求繁琐的委托模式,这是非常不方便实现的。 NSXMLDocument 有一点好用,但只能在 Mac OS X 工作, 但占用大量内存。

Ono 使得处理 XML & HTML 像 JSON 一样棒。

不管你的 app 是否需要 XML-RPC web服务的接口,爬一个网页,或者解析一个 RSS feed,Ono 会让你的工作更轻松。

特性

  • 简单,现代的 API 遵循标准 Objective-C 公约,包括扩展使用块和 NSFastEnumeration

  • 极高性能文档解析和遍历, powered by libxml2

  • 支持 XPath 和 CSS 查询

  • 自动转换的日期和数字值

  • 正确,正常地处理元素和属性的 XML 命名空间

  • 能够从 NSString 或 NSData 加载 HTML 和 XML 文档

  • 完整文档

  • 全面的测试套件

使用:

#import "Ono.h"
NSData *data = ...;
NSError *error;
ONOXMLDocument *document = [ONOXMLDocument XMLDocumentWithData:data error:&error];
for (ONOXMLElement *element in document.rootElement.children) {
    NSLog(@"%@: %@", element.tag, element.attributes);
}
// Support for Namespaces
NSString *author = [[document.rootElement firstChildWithTag:@"creator" inNamespace:@"dc"] stringValue];
// Automatic Conversion for Number & Date Values
NSDate *date = [[document.rootElement firstChildWithTag:@"created_at"] dateValue]; // ISO 8601 Timestamp
NSInteger numberOfWords = [[[document.rootElement firstChildWithTag:@"word_count"] numberValue] integerValue];
BOOL isPublished = [[[document.rootElement firstChildWithTag:@"is_published"] numberValue] boolValue];
// Convenient Accessors for Attributes
NSString *unit = [document.rootElement firstChildWithTag:@"Length"][@"unit"];
NSDictionary *authorAttributes = [[document.rootElement firstChildWithTag:@"author"] attributes];
// Support for XPath & CSS Queries
[document enumerateElementsWithXPath:@"//Content" usingBlock:^(ONOXMLElement *element, NSUInteger idx, BOOL *stop) {
    NSLog(@"%@", element);
}];


本文地址:https://www.codercto.com/soft/d/2716.html

Coding the Matrix

Coding the Matrix

Philip N. Klein / Newtonian Press / 2013-7-26 / $35.00

An engaging introduction to vectors and matrices and the algorithms that operate on them, intended for the student who knows how to program. Mathematical concepts and computational problems are motiva......一起来看看 《Coding the Matrix》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具