Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using simple C++ in Visual Studio Express. I dont know how to parse XML in C++. What to do??

I was thinking of exporting XML classes from .NET as COM, and use it in C++..
How to do that if possible. plz guide me..
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-12 12:53pm    
What to do? To use "Improve question" and provide a bit more information, primarily in tags.

It depends on the type of the project. Is this C++/CLI (for .NET, SLR platform), a native code, mixed-mode code, what. In other words, to know what libraries you can use, one needs to know what's the platform (don't tell us "Windows", this is not a complete characteristic of a platform), or application type.
--SA

First of all, is your XML file a simple/small DOM file or a large XML, like a database?

If it is the first one, then use MSXML parser:
Parsing an XML file in a C/C++ program[^]
How to create a simple XML file using MSXML in C++[^]

If it is a large XML file - use one of so many-many implementations of C++ parsers like ones published on this forum or elsewhere, as was already suggested.
 
Share this answer
 
v3
There are so many possible solutions that the answer would deserve an article. And searching on Codeproject.com would bring lots of acceptable results. But if you need a relatively simple parser from native C++ code on Windows then XmlLite[^] from Microsoft can be recommended first.
Quote from MSDN article A Small And Fast XML Parser For Native C++[^]:
"Due to the simplicity of its design, XmlLite manages to provide considerably better performance, even when compared to the MSXML SAX2 implementation. Although the SAX2 parser is better at handling large documents than the DOM implementation, it pales in comparison to XmlLite.
Simply put, XmlLite outperforms MSXML and it is much easier to use from native C++. MSXML will remain the most viable solution for Visual Basic and COM-based scripting languages, but now native Visual C++® finally has an XML parser designed specifically for it."
 
Share this answer
 
v2
Use one of the many c++ XML classes that you can find here on code project.

We use our own class as a wrapper around MSXML.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900