Skip to content
Light-weight, simple and fast XML parser for C++ with XPath support
C++ CMake PowerShell Makefile Lua Python Other
Branch: master
Clone or download
zeux Cleanup first_element_by_path
Instead of performing a late null check that is redundant and only
needed to silence clang static analysis warning, we pick the context as
a root / self node. This way the code is a bit less redundant and the
static analyzer is happy.
Latest commit 53a30c6 Dec 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Custom precision (#300) Sep 22, 2019
scripts Update `check` command to output text on failure Oct 1, 2019
src Cleanup first_element_by_path Dec 4, 2019
tests Custom precision (#300) Sep 22, 2019
.codecov.yml Add .codecov.yml to disable PR comments Aug 8, 2016
.gitattributes Add .gitattributes file Jul 24, 2018
.gitignore Update .gitignore Jun 21, 2017
.travis.yml Move unreachable line handling to Makefile Dec 10, 2018
CMakeLists.txt 🐛 Fix incorrect installation location for exported CMake targets Oct 18, 2019
LICENSE.md Happy New Year! Jan 1, 2019
Makefile Add LICENSE.md to RELEASE (#295) Sep 16, 2019
README.md Update README.md Apr 12, 2018
appveyor.yml
readme.txt Update version to 1.10 Sep 12, 2019

README.md

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:

You’re 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).

You can’t perform that action at this time.