No description
Find a file
Mai-Lapyst 4b2a560506
All checks were successful
/ test (push) Successful in 9s
Fix gitignore and add tests
2025-11-13 17:16:55 +01:00
.forgejo/workflows Initial commit; v0.1.0 2025-11-13 17:11:27 +01:00
src Initial commit; v0.1.0 2025-11-13 17:11:27 +01:00
tests Fix gitignore and add tests 2025-11-13 17:16:55 +01:00
.gitignore Fix gitignore and add tests 2025-11-13 17:16:55 +01:00
LICENSE Initial commit; v0.1.0 2025-11-13 17:11:27 +01:00
pugixml.nimble Initial commit; v0.1.0 2025-11-13 17:11:27 +01:00
readme.md Fix readme example 2025-11-13 17:14:49 +01:00

pugixml bindings for nim

This project contains a nimble package that provides pugixml bindings to nim using it's importcpp pragma's and the cpp backend.

License

This Software is licensed under the AGPL-3.0-only. For more details please see the LICENSE file.

Usage

The usage is largely the same as the pugixml c++ library.

Example

import pugixml;

when isMainModule:
    var doc: XmlDocument = newXmlDocument()
    doAssert doc.load_file("./test.xml").status = XmlParseStatus.ok
    echo $doc
import pugixml;

when isMainModule:
    var doc: XmlDocument = newXmlDocument()
    var recipe: XmlNode = doc.append_child("recipe")
    discard recipe.append_attribute("name").set_value("Chocolate cake")

    var ingredients: XmlNode = recipe.append_child("ingredients")

    discard ingredients.append_child("ingredient")
        .append_attribute("name").set_value("Chocolate")

    discard ingredients.append_child("ingredient")
        .append_attribute("name").set_value("Cake")

    discard recipe.append_child("instructions")
        .append_child(XmlNodeType.pcdata)
        .set_value("Combine Cocolate and cake.")

    echo $doc

    # Will print:
    # <?xml version="1.0"?>
    # <recipe name="Chocolate cake">
    #     <ingredients>
    #         <ingredient name="Chocolate" />
    #         <ingredient name="Cake" />
    #     </ingredients>
    #     <instructions>Combine Cocolate and cake.</instructions>
    # </recipe>