Godots internal XML Parser was alone not able to suit my usecases. I created a wrapper to create Godot Nodes from the XML File. This XmlNodes are also able to write a XML File to save it. I need XML for a project so this was the only option.
- written in GDScript
- Loading XML
- and turning them into XmlNode instances that can be placed into a scene.
- Saving a XML
- XMLs can be created by simple adding nodes in the editor
- Support for closing and empty tags
- needed because the other side handels it different
- yes its castor is empty string and is null
- simple escaping and unescaping for text (if you find problems please report it on my github)
Copy the addons folder into your projects root folder.
- Best use is create a root node with "XmlNode.newNode" or "XmlNode.newNodeWithText"
- then add nodes to this root
- the return values from all "addNode*" commands is the new created node
- its not a fluent interface!
var root:XmlNode = XmlNode.newNodeWithText("root", "Text")
root.addAttributes("Att1", "A")
root.addAttributes("Att2", "B")
root.addComment("Test Comment")
root.addNode("A1")
root.addNodeWithText("A2", "A2Text")
root.addNodeClosed("A3")
root.addNode("A4").addCData("CDATA-HERE-ADDED")
var xmlFile:String = root.writeXmlLine()
xml_loaded.text = xmlFile
print(xmlFile)
<root Att1="A" Att2="B">
Text
<!-- Test Comment -->
<A1></A1>
<A2>A2Text</A2>
<A3/>
<A4><![CDATA[CDATA-HERE-ADDED]]></A4>
</root>
Github: https://github.com/TheRealBlackNet/GodotXmlNodes
- cdata escaping
- escaping from attrtibutes
- current default space to underline for keys
- no " escaping
- walking the scene tree and ignore the non XMLNodes to have composition possible. then each xmlnode could use the same preWrite event and grabbing parent and get information from there.