:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the XMLParser.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_XMLParser: XMLParser ========= **Inherits:** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Low-level class for creating parsers for XML files. Methods ------- +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_attribute_count` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_attribute_name` **(** :ref:`int` idx **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_attribute_value` **(** :ref:`int` idx **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_current_line` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_named_attribute_value` **(** :ref:`String` name **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_named_attribute_value_safe` **(** :ref:`String` name **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_node_data` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_node_name` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_node_offset` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`NodeType` | :ref:`get_node_type` **(** **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_attribute` **(** :ref:`String` name **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_empty` **(** **)** const | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`open` **(** :ref:`String` file **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`open_buffer` **(** :ref:`PoolByteArray` buffer **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`read` **(** **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`seek` **(** :ref:`int` position **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`skip_section` **(** **)** | +------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+ Enumerations ------------ .. _enum_XMLParser_NodeType: .. _class_XMLParser_constant_NODE_NONE: .. _class_XMLParser_constant_NODE_ELEMENT: .. _class_XMLParser_constant_NODE_ELEMENT_END: .. _class_XMLParser_constant_NODE_TEXT: .. _class_XMLParser_constant_NODE_COMMENT: .. _class_XMLParser_constant_NODE_CDATA: .. _class_XMLParser_constant_NODE_UNKNOWN: enum **NodeType**: - **NODE_NONE** = **0** --- There's no node (no file or buffer opened) - **NODE_ELEMENT** = **1** --- Element (tag) - **NODE_ELEMENT_END** = **2** --- End of element - **NODE_TEXT** = **3** --- Text node - **NODE_COMMENT** = **4** --- Comment node - **NODE_CDATA** = **5** --- CDATA content - **NODE_UNKNOWN** = **6** --- Unknown node Description ----------- This class can serve as base to make custom XML parsers. Since XML is a very flexible standard, this interface is low level so it can be applied to any possible schema. Method Descriptions ------------------- .. _class_XMLParser_method_get_attribute_count: - :ref:`int` **get_attribute_count** **(** **)** const Get the amount of attributes in the current element. ---- .. _class_XMLParser_method_get_attribute_name: - :ref:`String` **get_attribute_name** **(** :ref:`int` idx **)** const Get the name of the attribute specified by the index in ``idx`` argument. ---- .. _class_XMLParser_method_get_attribute_value: - :ref:`String` **get_attribute_value** **(** :ref:`int` idx **)** const Get the value of the attribute specified by the index in ``idx`` argument. ---- .. _class_XMLParser_method_get_current_line: - :ref:`int` **get_current_line** **(** **)** const Get the current line in the parsed file (currently not implemented). ---- .. _class_XMLParser_method_get_named_attribute_value: - :ref:`String` **get_named_attribute_value** **(** :ref:`String` name **)** const Get the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute. ---- .. _class_XMLParser_method_get_named_attribute_value_safe: - :ref:`String` **get_named_attribute_value_safe** **(** :ref:`String` name **)** const Get the value of a certain attribute of the current element by name. This will return an empty :ref:`String` if the attribute is not found. ---- .. _class_XMLParser_method_get_node_data: - :ref:`String` **get_node_data** **(** **)** const Get the contents of a text node. This will raise an error in any other type of node. ---- .. _class_XMLParser_method_get_node_name: - :ref:`String` **get_node_name** **(** **)** const Get the name of the current element node. This will raise an error if the current node type is not :ref:`NODE_ELEMENT` nor :ref:`NODE_ELEMENT_END` ---- .. _class_XMLParser_method_get_node_offset: - :ref:`int` **get_node_offset** **(** **)** const Get the byte offset of the current node since the beginning of the file or buffer. ---- .. _class_XMLParser_method_get_node_type: - :ref:`NodeType` **get_node_type** **(** **)** Get the type of the current node. Compare with ``NODE_*`` constants. ---- .. _class_XMLParser_method_has_attribute: - :ref:`bool` **has_attribute** **(** :ref:`String` name **)** const Check whether or not the current element has a certain attribute. ---- .. _class_XMLParser_method_is_empty: - :ref:`bool` **is_empty** **(** **)** const Check whether the current element is empty (this only works for completely empty tags, e.g. ). ---- .. _class_XMLParser_method_open: - :ref:`Error` **open** **(** :ref:`String` file **)** Open a XML file for parsing. This returns an error code. ---- .. _class_XMLParser_method_open_buffer: - :ref:`Error` **open_buffer** **(** :ref:`PoolByteArray` buffer **)** Open a XML raw buffer for parsing. This returns an error code. ---- .. _class_XMLParser_method_read: - :ref:`Error` **read** **(** **)** Read the next node of the file. This returns an error code. ---- .. _class_XMLParser_method_seek: - :ref:`Error` **seek** **(** :ref:`int` position **)** Move the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code. ---- .. _class_XMLParser_method_skip_section: - void **skip_section** **(** **)** Skips the current section. If the node contains other elements, they will be ignored and the cursor will go to the closing of the current element.