Giter Site home page Giter Site logo

godotxml's Introduction

GodotXML - advanced XML support for Godot 4.

This addon adds support for manipulating XML data in Godot 4 with ease.

Supports Godot 4.0-4.2, and likely future versions too.

HINT: Migrating from v1? See changelog for a complete list of breaking (and not) changes.

Features

  • Pure-Godot - everything is done using built-in XMLParser;
  • Loading and dumping XML data into/from a convenient class-based format;
  • Beautifying XML;
  • Converting XML into dictionaries;
  • Access uniquely named children of nodes as if they were regular attributes (works in the editor too!);
  • Decent error messages for when the input is malformed (i mean, XMLParser doesn't have them at all, so :> ).

Installation

Search for the "GodotXML" addon on the asset library (link) or alternatively copy the addons/ folder into your project's root.

API

All functions and attributes that are meant for use by you do not have _ before their name and are also listed before any internal function.

All other functions and attributes are not meant to be used by you, though of course you can edit them as you like.

Roadmap

  • Setup automated tests.

godotxml's People

Contributors

elenakrittik avatar kiisu-master avatar suero152 avatar tokomine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

godotxml's Issues

Improve typing

There are quite a few places in code with missing or redundant type hints. These shall be fixed

Blank space in `XMLNode.content` is trimmed away.

The problem is that when you have a node with content that has spaces, these spaces will get removed from the edges when parsing.

Yep, that's intentional (but can be reverted, of course). I did it because i don't think that with, e.g.:

<node>
  Hello!
</node>

..one would expected the content to be "\n Hello!\n". At the same time i recognize that this practically forbids you from having multiline content, but that's an intentional trade-off i made in my mind when i've written it. Personally, my rule of thumb is "single-line data => make it an attribute; multi-line data => make it a CDATA", but i'm always open to feedback and we can change that (under an option).

Reading the comment, it seems like a workaround for a Godot xml parser problem?

In this case, it's more of an "unwanted" thing than an "issue" (the _cleanup_double_blankets() function below does exist to workaround an issue, but i assume that's out of your concern?).

Originally posted by @elenakrittik in #26 (comment)

It's probably better to leave trimming to the user, but i'm afraid of this being too breaking

Character escaping

We currently don't transform sequences like &quot when parsing, nor do we escape characters when dumping.

<![CDATA[ ]]> Is being ignored and do not appear as a content

content Is being ignored and do not appear as a children content

Parsed Dictionary:

{
   "__name__":"entry",
   "__content__":"",
   "attrs":{
      
   },
   "children":{
      "title":{
         "__name__":"title",
         "__content__":"",
         "attrs":{
            
         },
         "children":{
            
         }
      },
      "link":{
         "__name__":"link",
         "__content__":"",
         "attrs":{
            "rel":"alternate",
            "href":"https://xxxx.com/blog/dfssdfa33"
         },
         "children":{
            
         }
      },
      "id":{
         "__name__":"id",
         "__content__":"https://xxxx.com/33",
         "attrs":{
            
         },
         "children":{
            
         }
      },
      "author":{
         "__name__":"author",
         "__content__":"",
         "attrs":{
            
         },
         "children":{
            "name":{
               "__name__":"name",
               "__content__":"",
               "attrs":{
                  
               },
               "children":{
                  
               }
            }
         }
      },
      "summary":{
         "__name__":"summary",
         "__content__":"",
         "attrs":{
            "type":"html"
         },
         "children":{
            
         }
      },
      "updated":{
         "__name__":"updated",
         "__content__":"2024-02-29T03:50:32+00:00",
         "attrs":{
            
         },
         "children":{
            
         }
      }
   }
}

Original XML:

<entry>
<title>
<![CDATA[ Oieee ]]>
</title>
<link rel="alternate" href="https://xxxx.com/blog/dfssdfa33"/>
<id>https://xxxx.com/33</id>
<author>
<name>
<![CDATA[ Suerin ]]>
</name>
</author>
<summary type="html">
<![CDATA[ sfdfgsfgddfg ]]>
</summary>
<updated>2024-02-29T03:50:32+00:00</updated>
</entry>
</feed>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.