iOS的轻量级XML解析库 TBXML
- 授权协议: BSD
- 开发语言: Objective-C
- 操作系统: OS X
- 软件首页: http://www.tbxml.co.uk/TBXML/TBXML_Free.html
- 软件文档: http://www.tbxml.co.uk/TBXML/TBXML-Books.zip
软件介绍
TBXML是一个用于iOS上的解析速度非常快的轻量级XML解析库。提供了非常简洁的接口,使用起来很简单。
它提供了可以通过文件路径、URL、XML文件内容、内容字符串等方式载入XML文件,提供了获取XML节点和属性值的方法,以及一个遍历节点的方法。不过TBXML只提供了读的功能。
初始化和释放TBXML
TBXML* tbxml =[ [[TBXML alloc] initWithXMLFile:@"file.xml"] retain];
一定要在后面加上retain,要不运行app时,会出现非法访问的错误。
使用完毕后,注意释放:
[tbxml release];
使用递归方法遍历所有节点和属性的例子
- (void) traverseElement:(TBXMLElement *)element {
do {
// 显示XML元素名称
NSLog(@"%@",[TBXML elementName:element]);
// 获取到当前节点的第一个属性
TBXMLAttribute * attribute = element->firstAttribute;
// if attribute is valid
while (attribute) {
// 在log窗口中显示属性的名称和值
NSLog(@"%@->%@ = %@",[TBXML elementName:element],[TBXML attributeName:attribute], [TBXML attributeValue:attribute]);
// 获取下一个属性
attribute = attribute->next;
}
// 递归遍历下一个子元素
if (element->firstChild) [self traverseElement:element->firstChild];
// 获取同级元素
} while ((element = element->nextSibling));
}
The Smashing Book
Jacob Gube、Dmitry Fadeev、Chris Spooner、Darius A Monsef IV、Alessandro Cattaneo、Steven Snell、David Leggett、Andrew Maier、Kayla Knight、Yves Peters、René Schmidt、Smashing Magazine editorial team、Vitaly Friedman、Sven Lennartz / 2009 / $ 29.90 / € 23.90
The Smashing Book is a printed book about best practices in modern Web design. The book shares technical tips and best practices on coding, usability and optimization and explores how to create succes......一起来看看 《The Smashing Book》 这本书的介绍吧!
