Light-weight, simple and fast XML parser for C++ with XPath support
Find a file
Isabella Muerte 1c5a0bb325 Update CMake to modern approach
New Features:

pugixml-shared and pugixml-static are "always" available, but not always
built. This allows downstream projects to still use them, and to make
sure our configurations are correct regardless of if they are being
built. They are not always installed however.

pugixml-shared and pugixml-static have ALIAS libraries of
pugixml::shared and pugixml::static respectively. These names are also
respected in the `find_package(pugixml CONFIG)` generated files, so its
safe to use pugixml in a CMake project regardless of whether it is
installed locally, or if its a subproject via `add_subdirectory`.

pugixml will automatically select the correct library type based on
BUILD_SHARED_LIBS. A pugixml::pugixml ALIAS is also available.

CMAKE_MSVC_RUNTIME_LIBRARY from CMake 3.15 has been backported.

CMake will now rely on generator expressions (a powerful abstraction in
large projects with many subdirectories) for most work. This offloads
work from the single-threaded configure stage to the multithreaded
generation stage.

pugixml now uses CTest as the runner.

Some settings are automatically disabled if pugixml is used as a
subdirectory. These are still able to be manually set, but are hidden
from folks who choose to use CMake GUI.
2019-09-28 13:02:55 -07:00
docs Custom precision (#300) 2019-09-22 08:42:41 -07:00
scripts Move pugixml.rc to scripts/ 2019-09-21 09:21:13 -07:00
src Custom precision (#300) 2019-09-22 08:42:41 -07:00
tests Custom precision (#300) 2019-09-22 08:42:41 -07:00
.codecov.yml Add .codecov.yml to disable PR comments 2016-08-08 08:23:42 -07:00
.gitattributes Add .gitattributes file 2018-07-23 23:13:02 -07:00
.gitignore Update .gitignore 2017-06-20 21:11:35 -07:00
.travis.yml Move unreachable line handling to Makefile 2018-12-10 11:12:13 -08:00
appveyor.yml Update nuget creation to VS2019 (#291) 2019-09-09 07:37:29 -07:00
CMakeLists.txt Update CMake to modern approach 2019-09-28 13:02:55 -07:00
LICENSE.md Happy New Year! 2019-01-01 23:05:04 +03:00
Makefile Add LICENSE.md to RELEASE (#295) 2019-09-16 14:21:48 -07:00
pugixml-config.cmake.in Update CMake to modern approach 2019-09-28 13:02:55 -07:00
README.md Update README.md 2018-04-12 10:07:26 -07:00
readme.txt Update version to 1.10 2019-09-11 21:09:50 -07:00

pugixml Build Status Build status codecov.io MIT

pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving).

pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface.

Documentation

Documentation for the current release of pugixml is available on-line as two separate documents:

Youre advised to start with the quick-start guide; however, many important library features are either not described in it at all or only mentioned briefly; if you require more information you should read the complete manual.

Example

Here's an example of how code using pugixml looks; it opens an XML file, goes over all Tool nodes and prints tools that have a Timeout attribute greater than 0:

#include "pugixml.hpp"
#include <iostream>

int main()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("xgconsole.xml");
    if (!result)
        return -1;
        
    for (pugi::xml_node tool: doc.child("Profile").child("Tools").children("Tool"))
    {
        int timeout = tool.attribute("Timeout").as_int();
        
        if (timeout > 0)
            std::cout << "Tool " << tool.attribute("Filename").value() << " has timeout " << timeout << "\n";
    }
}

And the same example using XPath:

#include "pugixml.hpp"
#include <iostream>

int main()
{
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file("xgconsole.xml");
    if (!result)
        return -1;
        
    pugi::xpath_node_set tools_with_timeout = doc.select_nodes("/Profile/Tools/Tool[@Timeout > 0]");
    
    for (pugi::xpath_node node: tools_with_timeout)
    {
        pugi::xml_node tool = node.node();
        std::cout << "Tool " << tool.attribute("Filename").value() <<
            " has timeout " << tool.attribute("Timeout").as_int() << "\n";
    }
}

License

This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).