RepositoryC++USUnited States
ZE

zeux/pugixml

Light-weight, simple and fast XML parser for C++ with XPath support

4.7kstars
814forks
11issues
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: xml-parser

#1 Repository of the week

1
TINIX TRENDING·Topic: xpath

#1 Repository of the week

2
TINIX TRENDING·Topic: dom

#2 Repository of the week

pugixml Actions 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).

This work is based on the pugxml parser, which carried the following Public Domain dedication:

// Pug XML Parser - Version 1.0002
// --------------------------------------------------------
// Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
// Released into the Public Domain. Use at your own risk.
// See pugxml.xml for further information, history, etc.
// Contributions by Neville Franks (readonly@getsoft.com).

Similar Projects

Discover other similar projects and AI models.

RepositoryPHP
Imangazaliev/DiDOM

Simple and fast HTML and XML parser

2.2k
Jan 28, 2026
RepositoryGo
beevik/etree

Parse, query and modify XML easily in go

1.7k
Sep 23, 2026
RepositoryJava
jhy/jsoup

jsoup: the Java HTML parser, built for HTML editing, cleaning, scraping, and XSS safety.

11.4k
Nov 18, 2026
RepositoryTypeScript
fb55/htmlparser2

The fast & forgiving HTML and XML parser

4.8k
Dec 1, 2026
RepositoryJavaScript
posthtml/posthtml

PostHTML is a tool to transform HTML/XML with JS plugins

3.0k
Nov 26, 2026
RepositoryRust
tafia/quick-xml

Rust high performance xml reader and writer

1.6k
Nov 25, 2026
RepositoryC
libexpat/libexpat

:herb: Fast streaming XML parser written in C99 with >90% test coverage; moved from SourceForge to GitHub

1.4k
Nov 28, 2026
RepositoryPython
scrapy/parsel

Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors

1.4k
Nov 12, 2026
RepositorySwift
cezheng/Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support

1.1k
Jul 12, 2024