原文转载于:https://www.zhihu.com/question/32046606
作者:叛逆者
链接:https://www.zhihu.com/question/32046606/answer/55728362
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
统一接口,目前封装了rapidxml
链接:https://www.zhihu.com/question/32046606/answer/55728362
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
https://github.com/fffaraz/awesome-cpp#xml
XML
这里有个相当全的列表
XML
XML is crap. Really. There are no excuses. XML is nasty to parse for humans, and it's a disaster to parse even for computers. There's just no reason for that horrible crap to exist. - Linus Torvalds
- Boost.PropertyTree - A property tree parser/generator that can be used to parse XML/JSON/INI/Info files. [Boost]
- Expat - An XML parser library written in C. [MIT]
- Libxml2 - The XML C parser and toolkit of Gnome. [MIT]
- libxml++ - An XML Parser for C++. [LGPL2]
- PugiXML - A light-weight, simple and fast XML parser for C++ with XPath support. [MIT]
- RapidXml - An attempt to create the fastest XML parser possible, while retaining useability, portability and reasonable W3C compatibility. [Boost]
- TinyXML - A simple, small, minimal, C++ XML parser that can be easily integrating into other programs. [zlib]
- TinyXML2 - A simple, small, efficient, C++ XML parser that can be easily integrating into other programs. [zlib]
- TinyXML++ - A completely new interface to TinyXML that uses MANY of the C++ strengths. Templates, exceptions, and much better error handling. [MIT]
- Xerces-C++ - A validating XML parser written in a portable subset of C++. [Apache2]
强烈推荐的是rapidxml
是时候上这张图了:
<img data-rawheight="1200" data-rawwidth="1139" src="https://pic4.zhimg.com/50/bae08303994bb81e53254f5f409b5500_hd.jpg" class="origin_image zh-lightbox-thumb" width="1139" data-original="https://pic4.zhimg.com/bae08303994bb81e53254f5f409b5500_r.jpg">![](https://i-blog.csdnimg.cn/blog_migrate/68a97edd5938484d85d2f7d2c39ca64c.png)
来源 xml parsing - What XML parser should I use in C++?
<img data-rawheight="1200" data-rawwidth="1139" src="https://pic4.zhimg.com/50/bae08303994bb81e53254f5f409b5500_hd.jpg" class="origin_image zh-lightbox-thumb" width="1139" data-original="https://pic4.zhimg.com/bae08303994bb81e53254f5f409b5500_r.jpg">
![](https://i-blog.csdnimg.cn/blog_migrate/68a97edd5938484d85d2f7d2c39ca64c.png)
来源 xml parsing - What XML parser should I use in C++?
推荐boost 的property tree
ini
json
xml
三种常用数据格式通吃。
现在是tinyxml2最好,解析性能要好,同时api还要设计的好用,rapidxml性能好,但是不如tinyxml2好用,tinyxml2只需要包含两个头文件,api也设计的很好
本人用过libxml, xercesc, tinyxml2, rapidxml
rapidxml性能最好,最适合用作配置存取
最近增加了rapidxml sax解析接口
详见: https://github.com/halx99/xmldrv3
统一接口,目前封装了rapidxml