Skip to content

TheRealBlackNet/GodotXmlNodes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GodotXmlNodes - XML to Nodes to XML

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.

Features

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

To install the addon

Copy the addons folder into your projects root folder.

To use the XmlNode's

  • 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!

Create a XML:

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)

Result

<root Att1="A" Att2="B">
	Text
	<!-- Test Comment -->
	<A1></A1>
	<A2>A2Text</A2>
	<A3/>
	<A4><![CDATA[CDATA-HERE-ADDED]]></A4>
</root>

Links

Github: https://github.com/TheRealBlackNet/GodotXmlNodes

TODOS

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

About

Godots XmlParser is bad to use on its own so I made a wrapper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published