XML parsing in C++ [duplicate] - c++

This question already has answers here:
What XML parser should I use in C++? [closed]
(6 answers)
Closed 3 years ago.
What's the best API I can use to do some simple XML read/writing? I'm using Visual Studios. Is there a standard one that I can use in the STD library? The sofwtare that I need it for maybe sold and can't be open source, so it will have to have a flexible license for commercial use.
EDIT: I am NOT using this for any SOAP, protocol or data-binding stuff, Im just using this to store information, as almost an alternative to a database (because in this instance it would be more efficient).

I love pugixml. It's fast, light weight, incredibly easy to use and embed in projects (I've used it in several at work, it's only ~3 files), and best of all, supports XPath 1.0 (which is awesome).
Edit: No, there isn't one in the standard library.
Edit Edit: About pugixml's license: it is distributed under the MIT license, which is about as permissive as you can get.

As far as I know, there's no standard library to read XML.
I found TinyXML a handy library. There's now a TinyXML 2 which I've not used.

I would recommand GSOAP. I know companies that use this in products they sell so licensing should not be an issue. It has features such as schema validation etc...

Microsoft offers an XML library called XmlLite.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms752838%28v=vs.85%29.aspx

Related

Generating classes from XML in C++ (but NOT using CodeSynthesisXSD)

We require the ability to generate C++ classes from XML (akin to JAXB in Java) but for commercial reasons do not wish to use CodeSynthesisXSD. Are there any other libraries out there that will allow this? The platform we are targeting is Windows.
We have been looking at xmlbeansxx but this has not been maintained for 5 years and requires an older version of Boost than we have currently in our system (and do not want to have multiple Boost versions).
CodeSynthesis XSD author here.
First of all, a small nitpick: CodeSynthesis XSD doesn't generate C++ classes from XML. It generates them from XML Schema. From your question it appears that XSD would have worked for you. So I assume you are actually looking to generate C++ from XML Schema.
Now to your question. I don't believe there is a usable and more liberally-licensed C++ tool out there that can do this. Also, if your XML vocabulary is fairly small (e.g., a configuration format), then you may consider using XSD under the free proprietary license. It allows you to use XSD in a commercial application without having to release your source code as long as the amount of the generated code is less than 10,000 lines. And, as the name suggests, it is free (as in no charge).

Very simple C/C++ XML Parser [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What XML parser should I use in C++?
It is generally required to parse application settings from local XML file under Linux platform and nothing more.
Requirements:
1. Can be used for commercial product
2. Free of charge
3. Easy to install (1 header file will be great)
4. Easy to use
5. Very stable
6. Unicode support
I think expat does everything you want.
I use Apache's xerces-c. It never gave me problems and you can find some useful info on Google, like: Tuto1.
Also, it is free of charge and you can use it commercial products.
have a look at boost::property_tree http://www.boost.org/doc/libs/1_52_0/doc/html/property_tree.html

Thrift vs Protocol buffers [duplicate]

This question already has answers here:
Biggest differences of Thrift vs Protocol Buffers? [closed]
(15 answers)
Closed 7 years ago.
I've been using PB for quite a while now, but, Thrift has constantly been at the back of my mind.
The primary advantages of thrift, as I see it are:
Native collections (i.e, vector, set etc) vs PBs repeated providing functionality similar to, but not quite like (no iterators unless you dig into RepeatedField which the documentation states "shouldn't be required in most cases").
A decent RPC implementation provided, instead of just hooks to plug your own in.
More officially supported languages (PB offers "official" support for Java, C++, Python)
The cons of Thrift:
The RPC implementation means I can't plug in my own (for example) encryption/authentication layer on top.
Windows support doesn't seem to be great.
PB definitely seems to have, if not better, more accessible documentation.
Neutral:
Unknown size of .lib/.dll on Windows (Thrift).
Large size of .lib on Windows (PB, but it does offer a -lite which is significantly smaller).
Speed wise, they both seem to be similar.
I'm not quite ready to take the plunge and switch to Thrift yet, can anyone offer me more pros/cons, or reasons to go one way or the other?
Thanks!
As I've said as "Biggest differences of Thrift vs Protocol Buffers?" topic :
Referring to Thrift vs Protobuf vs JSON comparison :
C++, Python, Java - in-box support in Protobuf and Thrift.
Protobuf support for other languages (including Lua, Matlab, Ruby, Perl, R, Php, OCaml, Mercury, Erlang, Go, D, Lisp) is available as Third Party Addons (btw. Here is SWI-Prolog support).
Protobuf has much better documentation and plenty of examples.
Protobuf objects are smaller
Protobuf is faster when unsing "optimize_for = SPEED"
Thrift has integrated RPC implementation, while for Protobuf RPC solutions are separated, but available (like Zeroc ICE ).
Protobuf is released under BSD-style license
Thrift is released under Apache license
Additionally, there are plenty of interesting additional tools available for those solutions, which might decide. Here are examples for Protobuf: Protobuf-wireshark , protobufeditor.
You might want to analyse your need first:
Do you need a protocol-agnostic format? For example, do you want to implement a custom protocol or need 100% portability? In such a case use PB.
If you are fine with the default protocol of Thrift, and you need a protocol to begin with, by all means, go with Thrift.
Hope this helps.
Our project's main reason to stick with Thrift over protocol buffers was that protocol buffers don't auto-generate a complete RPC server, and existing solutions for PB seemed to all be fairly unstable. Just my $0.02.
You need to specify your use case(s) in detail. Else this is a "Which is better, a car or a truck?" question.

C++ code/XML generation tools

I'm not sure what exactly the right term is, kind of like ORM using XML as the data store. Are there any decent tools which will autogenerate C++ classes (including data and serialization/deserialization) based on an XML schema? Or will create XML-sync code and schema based on a C++ class definition?
TinyXML is great but it's so old-school to spend all that time writing code to load/save XML data to classes. I've seen similar tools focused on SOAP/WSDL, but they generated all kinds of other code on top of the basics.
Any good open-source libraries out there?
The only thing I've seen that attempts to do this is CodeSynthesisXSD.
If you are looking for an open source and commercial licensed tool to auto-generate C++ classes, including data and serialization/deserialization, based on an XML schema, then I strongly recommend GSOAP. It is easy to use, compliant to industry standards, and actively maintained.
See also http://www.rpbourret.com/xml/XMLDataBinding.htm
I was disappointed with many other C++ XML tools that promise full data bindings but will fail to process more extensive sets of WSDLs and schemas such as ONVIF. Having to retool an entire project was a pain. I know that GSOAP will do the job. A winner IMHO.
Not open source, but won't XML Thunder work for you?

VC++ project: MSXML vs any other XML libraries

We are aware of MSXML, based on COM technologies. We want to use it for a VC++ project starting soon. Are there any other XML libraries do good compared to MSXML?
TinyXML - A C++ open source library
Will you be using the .Net Framework if so you may want to look at using linq to xml.
Take a look at RapidXML. Also, Boost.PropertyTree is an abstraction over property trees (XML, JSON, INI, INFO at the time of writing) and relies on RapidXML for its XML parser.
We ditched MSXML in favor of Xerces for our project, although Xerces is also a big, complicated beast. The TinyXML suggestion is probably a good one if it does everything you need it to. If you only need basic SAX model support (and not a DOM), then you might also consider expat which is one of the first widely used XML parsers.
LIBXML
"Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), it is free software available under the MIT License."
I have used it for many years on Win32 projects without problem. It supports both SAX and DOM style reading.
You must take a look at Microsoft XmlLite which is a pull parser for pure C++. The primary goals of XmlLite are ease of use, performance, and standards compliance.