問題描述
我正在尋找一個簡單、干凈、正確的 XML 解析器以在我的 C++ 項目中使用.我應(yīng)該自己寫嗎?
I am looking for a simple, clean, correct XML parser to use in my C++ project. Should I write my own?
推薦答案
RapidXML?RapidXML 是一個用 C++ 編寫的非??焖俸托⌒偷?XML DOM 解析器.它主要針對嵌入式環(huán)境、計算機游戲或任何其他需要可用內(nèi)存或 CPU 處理能力的應(yīng)用程序.RapidXML 在 Boost 軟件許可下獲得許可,其源代碼可免費獲得.
How about RapidXML? RapidXML is a very fast and small XML DOM parser written in C++. It is aimed primarily at embedded environments, computer games, or any other applications where available memory or CPU processing power comes at a premium. RapidXML is licensed under Boost Software License and its source code is freely available.
功能
- 解析速度(包括DOM樹建筑)接近速度在上執(zhí)行的 strlen 函數(shù)相同的數(shù)據(jù).
- 在現(xiàn)代 CPU(截至 2008 年)上,解析器吞吐量約10億每秒字符數(shù).看在線表演部分手冊.
- 代碼內(nèi)存占用小并創(chuàng)建了 DOM 樹.
- 僅標頭的實現(xiàn),簡化集成過程.
- 簡單的許可證,允許用于幾乎任何目的,無論是商業(yè)用途和非商業(yè)的,沒有任何義務(wù).
- 支持 UTF-8 和部分 UTF-16,UTF-32 編碼.
- 可移植的源代碼,沒有除了非常小的依賴項C++ 標準庫的子集.
- 這個子集非常小,可以如果使用,可以很容易地手動模擬不希望使用標準庫.
限制
- 解析器忽略 DOCTYPE聲明.
- 不支持 XML 命名空間.
- 解析器不檢查字符有效性.
- 解析器的接口沒有符合 DOM 規(guī)范.
- 解析器不檢查屬性唯一性.
來源:wikipedia.org://Rapidxml
根據(jù)您的用途,您可以使用 XML 數(shù)據(jù)綁定嗎?CodeSynthesis XSD 是 Code 開發(fā)的用于 C++ 的 XML 數(shù)據(jù)綁定編譯器在 GNU GPL 和專有許可證下合成和雙重許可.給定一個 XML 實例規(guī)范(XML Schema),它生成表示給定詞匯表以及解析和序列化代碼的 C++ 類.
Depending on you use, you may use an XML Data Binding? CodeSynthesis XSD is an XML Data Binding compiler for C++ developed by Code Synthesis and dual-licensed under the GNU GPL and a proprietary license. Given an XML instance specification (XML Schema), it generates C++ classes that represent the given vocabulary as well as parsing and serialization code.
CodeSynthesis XSD 的獨特功能之一是它支持兩種不同的 XML 模式到 C++ 的映射:內(nèi)存中的 C++/樹和面向流的 C++/解析器.C++/Tree 映射是具有樹狀內(nèi)存數(shù)據(jù)結(jié)構(gòu)的傳統(tǒng)映射.C++/Parser 是一種新的、類似于 SAX 的映射,它將存儲在 XML 實例文檔中的信息表示為特定于詞匯表的解析事件的層次結(jié)構(gòu).與 C++/Tree 相比,C++/Parser 映射允許處理無法放入內(nèi)存的大型 XML 文檔、執(zhí)行面向流的處理或使用現(xiàn)有的內(nèi)存表示.
One of the unique features of CodeSynthesis XSD is its support for two different XML Schema to C++ mappings: in-memory C++/Tree and stream-oriented C++/Parser. The C++/Tree mapping is a traditional mapping with a tree-like, in-memory data structure. C++/Parser is a new, SAX-like mapping which represents the information stored in XML instance documents as a hierarchy of vocabulary-specific parsing events. In comparison to C++/Tree, the C++/Parser mapping allows one to handle large XML documents that would not fit in memory, perform stream-oriented processing, or use an existing in-memory representation.
來源:wikipedia.org://CodeSynthesis XSD
這篇關(guān)于什么是 C++ 的最佳開放 XML 解析器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!