No description
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| pugixml.nimble | ||
| readme.md | ||
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>