您的位置:首页 > 其它

Some simple facts about XML (一)

2009-09-30 18:24 465 查看
libxml2是个不错的跨平台库。另外最近还简单试了一个tinyxml,很好用,不过很快放弃了。通常这些库都把整个XML放到内存里,parse成树结构,接下来各种处理都很方便。因为需要处理上百M的单个XML文件,载入就花很多时间。

现在知道的libxml2中用xmlTextReaderPtr可以实时读取。有用的函数就几个:

- xmlReaderForFile 打开文件

- xmlTextReaderRead 顺序读每个结点

- xmlTextReaderConstName 读取结点

- xmlTextReaderGetAttribute 读取属性

写xml也是几个简单的就够了

- xmlTextWriterStartDocument 打开文件

- xmlTextWriterStartElement

- xmlTextWriterEndElement

- xmlTextWriterWriteAttribute

- xmlTextWriterWriteFormatAttribute

- xmlTextWriterEndDocument

下面的文章讲的很好

C++的XML编程经验――LIBXML2库使用指南

http://www.blogjava.net/wxb_nudt/archive/2009/07/25/161340.html

博主新地址

http://blog.csdn.net/wxb_nudt/archive/2008/09.aspx

Libxml2 is the XML parser and toolkit written in the C language

Libxml2 was originally developed for the Gnome project, but doesn't have any dependencies on it or even the Linux platform

Libxml2 implements a number of existing standards related to markup languages.

The majors are: XML standard 1.0 including Namespaces, Base, URI, XPointer, XInclude, XPath, HTML 4.0 parser, Canonical XML 1.0, XML Schemas Part 2, xml:id, and XML Catalog working drafts.

Libxml2 includes basic FTP and HTTP clients so you don't have to write an extra layer of code just to find your documents. Libxml2 exports Push (progressive) and Pull (blocking) type parser interfaces for both XML and HTML. Libxml2 can do DTD validation at parse time, using a parsed document instance, or with an arbitrary DTD. Sister projects provide some additional goodies like XSLT 1.0 (from libxslt) and a DOM2 implementation is also in the works.

Useful Links

Libxml2: Everything You Need in an XML Library

http://www.developer.com/xml/article.php/3729826/Libxml2-Everything-You-Need-in-an-XML-Library.htm

http://www.zlatkovic.com/libxml.en.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: