Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.


Inherits: RefCounted < Object

Provides a low-level interface for creating parsers for XML files.


Provides a low-level interface for creating parsers for XML files. This class can serve as base to make custom XML parsers.

To parse XML, you must open a file with the open method or a buffer with the open_buffer method. Then, the read method must be called to parse the next nodes. Most of the methods take into consideration the currently parsed node.

Here is an example of using XMLParser to parse a SVG file (which is based on XML), printing each element and its attributes as a dictionary:

var parser ="path/to/file.svg")
while != ERR_FILE_EOF:
    if parser.get_node_type() == XMLParser.NODE_ELEMENT:
        var node_name = parser.get_node_name()
        var attributes_dict = {}
        for idx in range(parser.get_attribute_count()):
            attributes_dict[parser.get_attribute_name(idx)] = parser.get_attribute_value(idx)
        print("The ", node_name, " element has the following attributes: ", attributes_dict)



get_attribute_count ( ) const


get_attribute_name ( int idx ) const


get_attribute_value ( int idx ) const


get_current_line ( ) const


get_named_attribute_value ( String name ) const


get_named_attribute_value_safe ( String name ) const