問題描述
我正在尋找一個簡單、干凈、正確的 XML 解析器以在我的 C++ 項目中使用.我應該自己寫嗎?
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 解析器.它主要針對嵌入式環境、計算機游戲或任何其他需要可用內存或 CPU 處理能力的應用程序.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樹建筑)接近速度在上執行的 strlen 函數相同的數據.
- 在現代 CPU(截至 2008 年)上,解析器吞吐量約10億每秒字符數.看在線表演部分手冊.
- 代碼內存占用小并創建了 DOM 樹.
- 僅標頭的實現,簡化集成過程.
- 簡單的許可證,允許用于幾乎任何目的,無論是商業用途和非商業的,沒有任何義務.
- 支持 UTF-8 和部分 UTF-16,UTF-32 編碼.
- 可移植的源代碼,沒有除了非常小的依賴項C++ 標準庫的子集.
- 這個子集非常小,可以如果使用,可以很容易地手動模擬不希望使用標準庫.
限制
- 解析器忽略 DOCTYPE聲明.
- 不支持 XML 命名空間.
- 解析器不檢查字符有效性.
- 解析器的接口沒有符合 DOM 規范.
- 解析器不檢查屬性唯一性.
來源:wikipedia.org://Rapidxml
根據您的用途,您可以使用 XML 數據綁定嗎?CodeSynthesis XSD 是 Code 開發的用于 C++ 的 XML 數據綁定編譯器在 GNU GPL 和專有許可證下合成和雙重許可.給定一個 XML 實例規范(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++ 的映射:內存中的 C++/樹和面向流的 C++/解析器.C++/Tree 映射是具有樹狀內存數據結構的傳統映射.C++/Parser 是一種新的、類似于 SAX 的映射,它將存儲在 XML 實例文檔中的信息表示為特定于詞匯表的解析事件的層次結構.與 C++/Tree 相比,C++/Parser 映射允許處理無法放入內存的大型 XML 文檔、執行面向流的處理或使用現有的內存表示.
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
這篇關于什么是 C++ 的最佳開放 XML 解析器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!