ZWinXml - Simple C++ XML Library for Windows Programs

Copyright (C) Werner Zimmermann (


This C++ library allows to write simple programs which do read, modify and write XML files. ZWinXml does not try to be a competitor to full-fledged XML parsers like expat, xcerces, msxml and others. It even does not parse XML at all, but is only a C++ wrapper about the open source C libraries LIBXML and LIBXSLT. ZWinXml does only cover a small subset with the most frequently used functions of this powerful library.

ZWinXml can be used together with my GUI library ZWinLib or it can be used stand alone.

LIBXML and LIBXSLT are available for Windows and several other operating systems from They come with full source and extensive documentation. A binary version of the libraries (compiled for Visual C++) comes with ZWinXml (see subdirectory .\libxml). ZWinXml users should not need to deal with LIBXML and LIBXSLT directly. However, if more advanced XML processing than ZWinXml provides is needed, LIBXML and LIBXSLT functions can be used directly bypassing ZwinXml without problems.

I started to develop ZWinXml to use XML in my own programs and I'm still learning about XML. So this is work in progress. Nevertheless, if you dare, please feel free to use it ...

Please also have a look at ZWinXml's close friends ZWinLib for graphical user interfaces, ZWinSql for file based SQL database handling and ZWinCrypt for compression, encryption and hashing files, also available on the same web site.


This library is distributed as a zip file. To install, unzip it into your desired installation directory. You'll get the following directory structure:

To run one of the samples, go to the samples subdirectory and run the respective Sample...exe file. To recompile one of the samples, in a console window change to the the sample's directory and type 'nmake'. This assumes, that Visual C++ compiler, linker, resource editor and (n)make utility are available in the path of your console window.

If you need to recompile the library itself, in a console window change to the src directory and type 'nmake'.

To develop your own ZWinXml applications, create another subdirectory in the samples directory, copy the files from Sample11 or Sample12 into this new subdirectory and start modifying these files.

If you ever want to deinstall ZWinXml again (why should you? :--)) ) simply delete the installation directory and all its subdirectories. ZWinXml does not copy files into any other directory nor does it touch the registry.

Getting started

The ZWinXml library provides the following user relevant classes:

Basically a program can do the following things:

  1. Open an existing XML file and get its root node
            WXmlDoc *pDoc = WXmlDoc::LoadXmlDocument("XML FileName");       //Open XML file
            WXmlNode *pNode  = pDoc->GetRootNode();                         //Get the root node
  2. Traverse the node tree by recursively using
            if (pNode->GetChildCount()>0)                           //Find out, if the node has children
            { WXmlNode *pChildNode = pNode->GetFirstChildNode();    //Get the first child node
                        pChildNode = pChildNode->GetNextNode();     //Get the next child node
                        . . .
  3. To get info about a node's name, value and properties, use
            cout << "Node name: " << pNode->GetNodeName() << "  Node value: " << pNode->GetNodeValue();
            for (int i=0; i < pNode->GetPropertyCount(); i++)                                       
            { cout << "Property name: " << pNode->GetPropertyName(i) << "  Property value: " << pNode->GetPropertyValue(i);
  4. To modify a node's name, value and properties, use
            pNode->SetPropertyName("oldPropertyName", "newPropertyName");
            pNode->SetPropertyValue("propertyName", "newValue");
    Instead of specifying the property via its name, it can also be selected by its index value with 0 being the first property.

  5. To add or remove nodes or properties
            WXmlDoc *pNewNode=pDoc->AddChildNode(pParentNode, "newNodeName", "newNodeValue");
            pNode->AddProperty("newPropertyName", "newPropertyValue");
  6. To save the modified XML file call
            pXmlDoc->SaveXmlDocument("XML FileName");
Node names and values and property names and values are treated as strings. When changing names or values, no verification is made, if the new values are valid. A document can be verified against its associated DTD using WXmlDoc::ValidateAgainstDtd() or against its associated XML schema using WXmlDoc::ValidateAgainstSchema().

If an error occurs, textual information about the last error can be gathered by calling GetLastXmlErrorInfo().

To get more detailed usage information, have a look at the examples below and look into the detailed functional documentation in file "ZWinXml.chm" (generated by Doxygen from ZWinXml.h, included in ZWinXml's doc subdirectory).


The package comes with some example files:

More samples and additional programming tips may be added in later versions.

Please note: If you run these examples or other ZWinXml based programs, libxml2.dll and libxslt.dll, which reside in .\libxml\bin, must be accessible via the Windows path. To ensure this for these samples, run setpath.bat in the sample's subdirectory.

ZWinXml compatibility

ZWinXml was developed and tested with Microsoft Visual C++ 2003 ... 2017 (English version) and tested under Windows XP/7/10. Other versions of Visual C++ and Windows should work, but have not been tested. If you successfully run ZWinXml with other versions, please send the author a short note.

Release Notes

V0.1.0: First public beta release.
V0.2.0: Added XSL processing with class WXmlSxl. New function GetAndSaveHttpDocument().
V0.3.0: Added experimental XML schema processing.
V0.4.0: WXmlDoc::FindNode() reimplemented, now supports node name and node value search with wildcards.
V0.5.0: Updated LibXML to V2.06.26. WXmlDoc::FindNode() and Sample12 modified.
V0.6.a: Intermediate release with improved, but still buggy namespace support, Sample12 modified (not stable)

Disclaimer and copyright information

All files are provided in the hope, they might be useful, but without any warranty or support. You may use or modify them on your own risk in non-commercial applications. Even if this software is provided free of charge, it is no freeware. It is copyrighted by Werner Zimmermann.

LIBXML and LIBXSLT are developped and maintained by Daniel Veillard. They are distributed as free software under the MIT license. For details see LIBXML's web site.

Windows, Visual C++, Visual Studio, XML and other product names mentioned here may be trademarks or registered trademarks of their respective owners.

Programming tips

Sorry, none yet ...