Some simple facts about XML (一)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值