XML解析庫比較

xml4c         ------http://www.alphaworks.ibm.com/tech/xml4c
  IBM的XML   Parser,用c++語言寫就,功能超級強大。號稱支持多達100種字符編碼,能夠支持中文,
適合於大規模的xml應用。若只是很小範圍的應用,則非最佳選擇,畢竟,你需要“揹負”約12M左右的
dll的沉重負擔

Xerces c++    -------http://xml.apache.org/xerces-c
  Apache的XML項目,同樣是c++   實現,來源於IBM的xml4c,因此編程接口也是和xml4c一致的。但是
目前只支持少數的字符編碼,如ASCII,UTF-8,UTF-16等,不能處理包含中文字符的XML文檔。
    Xerces-C++   是一個非常健壯的XML解析器,它提供了驗證,以及SAX和DOM   API。XML驗證在文檔類型定
義(Document   Type   Definition,DTD)方面有很好的支持,並且在2001年12月增加了支持W3C   XML   Schema 
的基本完整的開放標準。
  
XMLBooster    -------http://www.xmlbooster.com/
        這個庫通過產生特製的parser的辦法極大的提高了XML解析的速度,並且能夠產生相應的GUI程序
來修改這個parser。在DOM和SAX兩大主流XML解析辦法之外提供了另外一個可行的解決方案。

libxml++      ----------- http://libxmlplusplus.sourceforge.net/     
  libxml++是對著名的libxml   XML解析器的C++封裝版本

 

TinyXML      -----http://sourceforge.net/

inyXML是一個開源的解析XML的解析庫,能夠用於C++,能夠在WindowsLinux中編譯。這個解析庫的模型通過解析XML文件,然後在內存中生成DOM模型,從而讓我們很方便的遍歷這棵XML樹。

可能因爲微軟、IBM這樣的商業公式和開源社區在數據表達方面的不謀而合,以及再加上W3C推波助瀾XML的相關技術總是和應用結合得非常緊密。XML從 產生就不乏優秀的工具。在最近一個項目中,我們就使用了原生的XML存儲數據庫Berkely DBXML(BDB)。
其實,DBXML使用了大量優秀的開源工具來實現,其中數據存儲使用Berkely DB,XML解析使用XercesC,XPath的實現使用Pathan(2.3以前),XQilla(2.3以後)。關於這幾個庫,我將官方網站的介紹摘錄如下:

  1. Xerces-C++ is a validating XML parser written in a portable subset of C++. Xerces-C++ makes it easy to give your application the ability to read and write XML data. A shared library is provided for parsing, generating, manipulating, and validating XML documents.
  2. Pathan is a open source library which allows developers using Xerces-C to parse and evaluate XPath expressions for XML node selection.
  3. XQilla is an XQuery and XPath 2 library and command line utility written in C++ , implemented on top of the Xerces-C. XQilla is originally based on an open source project called Pathan, that was hosted by Decisionsoft and implemented XPath 2. However, XQilla has been developed and improved considerably from the Pathan code base.
  4. Xalan is an XSLT processor for transforming XML documents into HTML, text, or other XML document types

    在接下來的工作中,我們希望把存儲的XML表達出來。我們通過XSL來實現XML的表達,有趣的是XSL
本身也是XML,又是一個有趣的遞歸。
把DBXML與XSL聯繫起來。我們找到了一個DBXML API中函數,他可以將XML Node 以Xerces DOMDocument 方式返回:

xercesc_2_6::DOMDocument *XmlDocument::getContentAsDOM() const;


    我們要還要引入一個庫Xalan C++。Xalan C++可以將生成的結果存儲在一個Xerces DOMDocument中;可以使用TransformToXercesDOM將XercesDOM作爲轉換的源。

    在XML開源軟件中還有一支,那就是來自MIT的xmlsoft.org。其中最著名的libxml2和基於libxml2的libxslt,均應用到 gnome上。這些都是C的API包,在此基礎上有C++綁定,PHP綁定,perl綁定等等。debian下的php-mod-xml就源自這裏。
    openoffice的OpenDocument基於XML,xml.openoffice.org上也有一些實現,同樣值得關注。

發佈了12 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章