Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to know how to read and write Xml files in pure C++ or C.
I can't use any .Net libraries and I'm using a blank Win32 C++ Project in Visual Studio 2010.
If possible I'd like to not use any 3rd party tools/code.
Posted
Comments
[no name] 5-Jul-12 14:37pm    
XML file are just text files so you open a file for writing, write data to it and then close the file. What is your real question?
shelby67 5-Jul-12 14:41pm    
How do I read data between tags like:

<menu>
<item id="0">Item 0</item>
</menu>



I want to retrieve the text "Item 0" if i search for the tag id.

Have a look at MSXML[^]

The header file is included with the Windows SDK:
#include <MsXml.h>


Best regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 5-Jul-12 15:35pm    
It is the answer, my 5.
--SA
Espen Harlinn 5-Jul-12 15:39pm    
Thank you, Sergey!
Spending the evening fixing bugs in an application I made last autumn - I believe I was a bit tired at the time, having just finished a rather large system. I should probably have gone on a holiday before I started something new :-(
shelby67 5-Jul-12 16:09pm    
I appreciate the link you gave me, but I can't seem to find a download for it. I'm under the assumption that I have ti download and import libraries into my project to get this to work.
Espen Harlinn 5-Jul-12 16:15pm    
It's probably already installed on your system. Try using OleView.Exe, usually installed in "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\Bin" or something similar. Look for "Microsoft XML, v6.0", "Microsoft XML, v5.0", "Microsoft XML, v4.0" under type libraries.
If you don't need xml validation (dtd, xsl, ...), xml namespaces and similar fancy stuff I would recommend using tinyxml that is hassle free to put into a c++ program and is platform independent.(we use it on win32, linux, android, iOS, ...). Its a very popular "simple drop-in" library.
 
Share this answer
 
Comments
Sergey Chepurin 6-Jul-12 15:37pm    
+5 for cross-platform solution, and this is a link to Tinyxml[^].

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