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

Overview

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

Issues
  • Enable long long by default (needed by filezilla)

    Enable long long by default (needed by filezilla)

    Currently the pugixml.hpp doesn't enable long long by default, as a result the fedora package has it disabled. For this reason the filezilla package (which requires the long long feature) cannot use the system pugixml.

    As a packager, we are often are reluctant to tweak upstream default options, so it would be easier if you can reword the condition to enable it by default, so pugixml will be available for in distributions as fully featured.

    opened by kwizart 24
  • cmake: avoid ALIAS target

    cmake: avoid ALIAS target

    This is not allowed on IMPORTED targets.


    @randyfan Sorry about that. Thanks for the report. I thought I had tested it, but apparently not.

    @zeux 1.11.2 it appears :/ .

    opened by mathstuf 20
  • binary is incompatible after update of VisualStudio 2017

    binary is incompatible after update of VisualStudio 2017

    After update of Visual Studio 2017 from version 15.0 to 15.3 I started getting the following errors:

    LINK : fatal error C1047: The object or library file 'C:\projects\build\msvs_solution\packages\pugixml.1.8.3\build\native\lib/Win32\v141\dynamic\Release\pugixml.lib' was created with an older compiler than other objects; rebuild old objects and libraries [C:\projects\build\msvs_solution\render_test\render_test.vcxproj]
    

    you can find the build log of my project here https://ci.appveyor.com/project/igagis/svgren/build/master-395

    Looks like the pugixml nuget package has to be rebuild with latest VS2017.

    build 
    opened by igagis 18
  • Cannot compile pugixml

    Cannot compile pugixml

    Hey, I tried to use pugixml for my current project but I am not able to compile it. Three errors occur:

    ..\pugixml-1.7\src\pugixml.cpp: In function 'long long int pugi::impl::{anonymous}::get_value_llong(const char_t*)':
    ..\pugixml-1.7\src\pugixml.cpp:4454:91: error: 'LLONG_MIN' was not declared in this scope
       return string_to_integer<unsigned long long>(value, 0 - static_cast<unsigned long long>(LLONG_MIN), LLONG_MAX);
                                                                                               ^
    ..\pugixml-1.7\src\pugixml.cpp:4454:103: error: 'LLONG_MAX' was not declared in this scope
       return string_to_integer<unsigned long long>(value, 0 - static_cast<unsigned long long>(LLONG_MIN), LLONG_MAX);
                                                                                                           ^
    ..\pugixml-1.7\src\pugixml.cpp: In function 'long long unsigned int pugi::impl::{anonymous}::get_value_ullong(const char_t*)':
    ..\pugixml-1.7\src\pugixml.cpp:4459:58: error: 'ULLONG_MAX' was not declared in this scope
       return string_to_integer<unsigned long long>(value, 0, ULLONG_MAX);
    

    Maybe you encountered this problem before.

    Best Regards

    Chris

    opened by chrisUHD 17
  • VS 2015 NuGet Package Static Multithreaded

    VS 2015 NuGet Package Static Multithreaded

    The VS 2013 library was compiled with static /MT linkage whereas the newer VS 2015 library was compiled with dynamic /MD linkage in the NuGet package.

    When upgrading our project to the VS 2015 C++ compiler, our projects that depend on the pugixml NuGet package were no longer able to link due to this change. Was this intended? And is there an option to change it or introduce support for static linking again?

    MS doc about linkage: https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx

    build 
    opened by steji113 16
  • cmake // Enable test invocation via CTest

    cmake // Enable test invocation via CTest

    Change will allow to run UT using CTest (ctest -VV) when -DBUILD_TESTS=ON

    • Added target 'make check', which will initiate 'build then test' operation.
    • Increased CMake requirements for 2.8
    opened by snikulov 15
  • umlaute in pcdata

    umlaute in pcdata

    Is there a way to special encode umlaute (öäü, ...) in pcdata when printing?

    ö -> &#246;
    

    Something like python is doing:

    import xml.etree.cElementTree as ET
    root = ET.Element("root")
    doc = ET.SubElement(root, "doc")
    ET.SubElement(doc, "node").text = "Hello Wö"
    tree = ET.ElementTree(root)
    tree.write("test_pcdata_python.xml")
    

    gives:

    <root><doc><node>Hello W&#246;</node></doc></root>
    

    With pugixml gives (flags=0, encoding=auto):

    ...
    x.append_child(pugi::node_pcdata).set_value(tmp.c_str());
    doc.print(buf, "", 0);
    
    <root><doc><node>Hello Wö</node></doc></root>
    
    opened by pamapa 14
  • Add void* user data to xml_node_struct

    Add void* user data to xml_node_struct

    like this:

        struct xml_node_struct
        {
                ...
                xml_attribute_struct* first_attribute;
                void* user_date;
        };
    

    and add 2 function mebers to xml_node like this

    PUGI__FN void xml_node::set_user_data(void* p)
    {
        if (_root)
        {
             _root->user_date = p;
        }
    }
    
    PUGI__FN void* xml_node::get_user_data()
    {
        return _root ? _root->user_date : 0;
    }
    

    english is pool , be sorry : (

    enhancement wontfix 
    opened by baixuefeng 12
  • Style Fixes

    Style Fixes

    (1) A few classes should be made non-copyable (2) C++11 semantics should be preferred to mark classes non-copyable (3) Added explicit to several contructors in oder to prevent implicit conversions

    opened by QuickJack 12
  • Reduce memory usage for immutable documents

    Reduce memory usage for immutable documents

    Work in this branch was not finished: https://code.google.com/p/pugixml/source/browse/#svn%2Fbranches%2Fimmutable Is there any chance for it to be completed?

    opened by annulen 12
  • Potential error in logic with custom allocator

    Potential error in logic with custom allocator

    Hello,

    I'm trying to use mmap to elimate some memory fragmentation in a long running process.

    From the output below, you can see that pugixml is trying to access a memory section immediately after releasing it. Is there a chance there's a logic error in the pugixml memory paging system, or does this look like user error?

    Allocating mmap: 0x7fffe3a90000 65536 Allocating mmap: 0x7fffe3a80000 65536 Allocating mmap: 0x7fffe3a70000 65536 Allocating mmap: 0x7fffe3a60000 65536 Allocating malloc: 0x7fffdee1b3a0 9 Allocating mmap: 0x7fffe3a50000 65536 Deallocating: 0x7fffdee1b3a0 9 Deallocated. Deallocating: 0x7fffe3a50000 65536 Deallocated. Deallocating: 0x7fffe3a90000 65536 Deallocated.

    Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff263b700 (LWP 15777)] pugi::xml_node::next_sibling ([email protected]=0x7ffff263a750) at /var/4d/servers/current/apps/engage/compiler/lib/pugixml/src/pugixml.cpp:4386 4386 if (_root->next_sibling) return xml_node(_root->next_sibling); (gdb) p _root *$1 = (pugi::xml_node_struct ) 0x7fffe3a955b0

    invalid 
    opened by homer6 11
  • No symbols exported with clang-cl

    No symbols exported with clang-cl

    Due to: https://github.com/zeux/pugixml/blob/3b5c1fb022dc286b0480ccafa9b79f832deb24ce/CMakeLists.txt#L114 No symbols get exported if pugixml gets build with clang-cl instead of cl.

    patch-welcome build 
    opened by Neumann-A 14
  • Add support non-zero-terminated strings (pointer+size, i.e. std::string_view)

    Add support non-zero-terminated strings (pointer+size, i.e. std::string_view)

    I use std::string_view extensively in my code, because it allows to make substrings very cheaply (requires only adjusting a couple of pointers instead of copying the string), but pugixml accepts only const char* arguments, which forces me to make local copies of strings.

    It would nice to have either a std::string_view overload, or const char*, size_t overload.

    opened by Hedede 1
  • Correctly set default visibility on non-windows compilers

    Correctly set default visibility on non-windows compilers

    This fixes compilation of pugixml with -fvisibility=hidden. Without this patch, one would get lots of unresolved symbols when consuming pugixml as a shared library.

    opened by milianw 2
  • locale independant float parsing with c++ 17

    locale independant float parsing with c++ 17

    With this fix, float parsing with "." decimal delimiter is correct when local uses another separator

    Fixex https://github.com/zeux/pugixml/issues/469 https://github.com/troldal/OpenXLSX/issues/133

    opened by gvollant 0
  • parsing float is local dependant

    parsing float is local dependant

    In France, decimal separator is "," and not "."

    strtod used in pugixml.cpp uses strtod which is local dependant

    possible alternative:

    1. use own double parsing code like https://github.com/michael-hartmann/parsefloat
    2. use std::from_chars is c++17 is detected
    opened by gvollant 4
Releases(v1.12.1)
TinyXML2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs.

TinyXML-2 TinyXML-2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs. The master is hosted on github: h

Lee Thomason 4.2k Aug 2, 2022
A library to serialize custom classes to and from XML by adding a very minimal amount of code to a class.

ai-xml submodule This repository is a git submodule providing a C++ framework for serializing classes to and from XML with a minimal amount of code pe

Carlo Wood 1 Feb 16, 2021
Tiny XML library.

Mini-XML Version 3.2 Mini-XML is a small XML parsing library that you can use to read XML data files or strings in your application without requiring

Michael R Sweet 347 Aug 3, 2022
Expat - a C library for parsing XML

Fast streaming XML parser written in C

Expat development team 770 Aug 5, 2022
A light-weight json parser.

pson pson is a lightweight parser and it support six type, null , bool, number, string, array, object, and it can parse the encoding of UTF-8. It's fa

pinK 15 Aug 6, 2022
Simple, Fast, Light weight

Welcome To PradoshOS Github! Index Main heading Setup Step 1 Step 2 Step 3 Step 4 Compilation of Bootloader Compilation of Kernel Compilation of Userl

S Pradosh 10 Aug 5, 2022
Harsh Badwaik 1 Dec 19, 2021
C XML Minimalistic Library (CXML) - An XML library for C with a focus on simplicity and ease of use.

cxml (C XML Minimalistic Library) is a powerful and flexible XML library for C with a focus on simplicity and ease of use, coupled with features that enables quick processing of XML documents.

null 28 Feb 11, 2022
BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser) See http://pypi.python.org/pypi/bllipparser/ for Python module.

BLLIP Reranking Parser Copyright Mark Johnson, Eugene Charniak, 24th November 2005 --- August 2006 We request acknowledgement in any publications that

Brown Laboratory for Linguistic Information Processing 212 Jul 19, 2022
BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser)

BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser)

Brown Laboratory for Linguistic Information Processing 212 Jul 19, 2022
Fast and Light-weight path smoothing methods for vehicles

path_smoother About Fast and Light-weight path smoothing methods for vehicles Denpendencies This project has been tested on Ubuntu 18.04. sudo apt-get

MingwangZhao 4 Dec 1, 2021
A very simple and light-weight drawing app made with qt and C++.

Blackboard A very simple and light-weight drawing app made with qt and C++. It supports tablet and pen pressure with the help of QTabletEvents. So you

null 1 Nov 15, 2021
TinyXML2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs.

TinyXML-2 TinyXML-2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs. The master is hosted on github: h

Lee Thomason 4.2k Aug 2, 2022
nanomsg-next-generation -- light-weight brokerless messaging

nng - nanomsg-next-gen ℹ️ If you are looking for the legacy version of nanomsg, please see the nanomsg repository. This project is a rewrite of the Sc

nanomsg 2.8k Aug 4, 2022
Poseidon OS (POS) is a light-weight storage OS

Poseidon OS Poseidon OS (POS) is a light-weight storage OS that offers the best performance and valuable features over storage network. POS exploits t

null 47 Jul 22, 2022
A light-weight Flutter Engine Embedder based on HADK ,which for Android devices that runs without any java code

flutter-hadk A light-weight Flutter Engine Embedder based on HADK ,which for Android devices that runs without any java code 1.Build by android-ndk-to

null 12 Jun 15, 2022
Light-weight UNIX backdoor

JadedWraith Lightweight UNIX backdoor for ethical hacking. Useful for red team engagements and CTFs. Something I wrote a few years ago as part of a ga

null 124 Jun 10, 2022
Analytics In Real-time (AIR) is a light-weight system profiling tool

Analytics In Real-time Analytics In Real-time (AIR) is a light-weight system profiling tool that provides a set of APIs for profiling performance, lat

null 2 Mar 3, 2022
Ducktape is an Open source Light weight 2d Game Engine that gives utmost priority to user convenience.

Ducktape is an Open source Light weight 2d Game Engine that gives utmost priority to user convenience. It is written in c++ and uses SFML and Box2d for graphics and physics respectively.

Ducktape 70 Aug 7, 2022
qpSWIFT is a light-weight sparse quadratic programming solver

qpSWIFT Light-weight sparse Quadratic Programming Solver Introduction qpSWIFT is light-weight sparse Quadratic Programming solver targetted for embedd

qpSWIFT 59 Jul 18, 2022
A light-weight music Discord bot using Orca.

What's the "Music Discord bot with C"? A light-weight music Discord bot using Orca for it's bot. It's easy to use and install. How to download and use

ThePedro 9 Jul 18, 2022
Decoding light morse code with a light dependent resistor and Arduino board

Morse decoder The project's idea is very simple, the Arduino program has the responsibility to upload the sensor's data to the USB serial port.

null 15 Mar 12, 2022
Fast C/C++ CSS Parser (Cascading Style Sheets Parser)

MyCSS — a pure C CSS parser MyCSS is a fast CSS Parser implemented as a pure C99 library with the ability to build without dependencies. Mailing List:

Alexander 119 Jun 18, 2022
C++ reflection library with Lua binding, and JSON and XML serialisation.

Ponder Linux & OSX: - Windows: Currents status: 3.2-alpha. API is unstable as features added/changed. New: Version 3 V1 replaced Boost with C++11. V2

Bill Quith 548 Jul 29, 2022
GPU Accelerated C++ User Interface, with WYSIWYG developing tools, XML supports, built-in data binding and MVVM features.

GacUI GPU Accelerated C++ User Interface, with WYSIWYG developing tools, XML supports, built-in data binding and MVVM features. Read the LICENSE first

Vczh Libraries 2.1k Jul 29, 2022
The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.

libxo libxo - A Library for Generating Text, XML, JSON, and HTML Output The libxo library allows an application to generate text, XML, JSON, and HTML

Juniper Networks 242 Jul 19, 2022
A library to serialize custom classes to and from XML by adding a very minimal amount of code to a class.

ai-xml submodule This repository is a git submodule providing a C++ framework for serializing classes to and from XML with a minimal amount of code pe

Carlo Wood 1 Feb 16, 2021