351 lines
14 KiB
ReStructuredText
351 lines
14 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/XMLParser.xml.
|
|
|
|
.. _class_XMLParser:
|
|
|
|
XMLParser
|
|
=========
|
|
|
|
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
Low-level class for creating parsers for `XML <https://en.wikipedia.org/wiki/XML>`__ files.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
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.
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Methods
|
|
-------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_attribute_count<class_XMLParser_method_get_attribute_count>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_attribute_name<class_XMLParser_method_get_attribute_name>` **(** :ref:`int<class_int>` idx **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_attribute_value<class_XMLParser_method_get_attribute_value>` **(** :ref:`int<class_int>` idx **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_current_line<class_XMLParser_method_get_current_line>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_named_attribute_value<class_XMLParser_method_get_named_attribute_value>` **(** :ref:`String<class_String>` name **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_named_attribute_value_safe<class_XMLParser_method_get_named_attribute_value_safe>` **(** :ref:`String<class_String>` name **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_node_data<class_XMLParser_method_get_node_data>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_node_name<class_XMLParser_method_get_node_name>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_node_offset<class_XMLParser_method_get_node_offset>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`NodeType<enum_XMLParser_NodeType>` | :ref:`get_node_type<class_XMLParser_method_get_node_type>` **(** **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_attribute<class_XMLParser_method_has_attribute>` **(** :ref:`String<class_String>` name **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_empty<class_XMLParser_method_is_empty>` **(** **)** |const| |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_XMLParser_method_open>` **(** :ref:`String<class_String>` file **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_buffer<class_XMLParser_method_open_buffer>` **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`read<class_XMLParser_method_read>` **(** **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`seek<class_XMLParser_method_seek>` **(** :ref:`int<class_int>` position **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`skip_section<class_XMLParser_method_skip_section>` **(** **)** |
|
|
+------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_XMLParser_NodeType:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **NodeType**:
|
|
|
|
.. _class_XMLParser_constant_NODE_NONE:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_NONE** = ``0``
|
|
|
|
There's no node (no file or buffer opened).
|
|
|
|
.. _class_XMLParser_constant_NODE_ELEMENT:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_ELEMENT** = ``1``
|
|
|
|
Element (tag).
|
|
|
|
.. _class_XMLParser_constant_NODE_ELEMENT_END:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_ELEMENT_END** = ``2``
|
|
|
|
End of element.
|
|
|
|
.. _class_XMLParser_constant_NODE_TEXT:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_TEXT** = ``3``
|
|
|
|
Text node.
|
|
|
|
.. _class_XMLParser_constant_NODE_COMMENT:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_COMMENT** = ``4``
|
|
|
|
Comment node.
|
|
|
|
.. _class_XMLParser_constant_NODE_CDATA:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_CDATA** = ``5``
|
|
|
|
CDATA content.
|
|
|
|
.. _class_XMLParser_constant_NODE_UNKNOWN:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **NODE_UNKNOWN** = ``6``
|
|
|
|
Unknown node.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_XMLParser_method_get_attribute_count:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_attribute_count** **(** **)** |const|
|
|
|
|
Gets the amount of attributes in the current element.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_attribute_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_attribute_name** **(** :ref:`int<class_int>` idx **)** |const|
|
|
|
|
Gets the name of the attribute specified by the index in ``idx`` argument.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_attribute_value:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_attribute_value** **(** :ref:`int<class_int>` idx **)** |const|
|
|
|
|
Gets the value of the attribute specified by the index in ``idx`` argument.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_current_line:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_current_line** **(** **)** |const|
|
|
|
|
Gets the current line in the parsed file (currently not implemented).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_named_attribute_value:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_named_attribute_value** **(** :ref:`String<class_String>` name **)** |const|
|
|
|
|
Gets the value of a certain attribute of the current element by name. This will raise an error if the element has no such attribute.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_named_attribute_value_safe:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_named_attribute_value_safe** **(** :ref:`String<class_String>` name **)** |const|
|
|
|
|
Gets the value of a certain attribute of the current element by name. This will return an empty :ref:`String<class_String>` if the attribute is not found.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_node_data:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_node_data** **(** **)** |const|
|
|
|
|
Gets the contents of a text node. This will raise an error in any other type of node.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_node_name:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_node_name** **(** **)** |const|
|
|
|
|
Gets the name of the current element node. This will raise an error if the current node type is neither :ref:`NODE_ELEMENT<class_XMLParser_constant_NODE_ELEMENT>` nor :ref:`NODE_ELEMENT_END<class_XMLParser_constant_NODE_ELEMENT_END>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_node_offset:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_node_offset** **(** **)** |const|
|
|
|
|
Gets the byte offset of the current node since the beginning of the file or buffer.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_get_node_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`NodeType<enum_XMLParser_NodeType>` **get_node_type** **(** **)**
|
|
|
|
Gets the type of the current node. Compare with :ref:`NodeType<enum_XMLParser_NodeType>` constants.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_has_attribute:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **has_attribute** **(** :ref:`String<class_String>` name **)** |const|
|
|
|
|
Check whether the current element has a certain attribute.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_is_empty:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_empty** **(** **)** |const|
|
|
|
|
Check whether the current element is empty (this only works for completely empty tags, e.g. ``<element \>``).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_open:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` file **)**
|
|
|
|
Opens an XML file for parsing. This returns an error code.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_open_buffer:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **open_buffer** **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)**
|
|
|
|
Opens an XML raw buffer for parsing. This returns an error code.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_read:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **read** **(** **)**
|
|
|
|
Reads the next node of the file. This returns an error code.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_seek:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **seek** **(** :ref:`int<class_int>` position **)**
|
|
|
|
Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_XMLParser_method_skip_section:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
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.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|