class_xmlparser.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/XMLParser.xml.
  6. .. _class_XMLParser:
  7. XMLParser
  8. =========
  9. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Low-level class for creating parsers for `XML <https://en.wikipedia.org/wiki/XML>`__ files.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_attribute_count<class_XMLParser_method_get_attribute_count>` **(** **)** |const| |
  22. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`String<class_String>` | :ref:`get_attribute_name<class_XMLParser_method_get_attribute_name>` **(** :ref:`int<class_int>` idx **)** |const| |
  24. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`String<class_String>` | :ref:`get_attribute_value<class_XMLParser_method_get_attribute_value>` **(** :ref:`int<class_int>` idx **)** |const| |
  26. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_current_line<class_XMLParser_method_get_current_line>` **(** **)** |const| |
  28. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`String<class_String>` | :ref:`get_named_attribute_value<class_XMLParser_method_get_named_attribute_value>` **(** :ref:`String<class_String>` name **)** |const| |
  30. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_String>` | :ref:`get_named_attribute_value_safe<class_XMLParser_method_get_named_attribute_value_safe>` **(** :ref:`String<class_String>` name **)** |const| |
  32. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`get_node_data<class_XMLParser_method_get_node_data>` **(** **)** |const| |
  34. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_String>` | :ref:`get_node_name<class_XMLParser_method_get_node_name>` **(** **)** |const| |
  36. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`get_node_offset<class_XMLParser_method_get_node_offset>` **(** **)** |const| |
  38. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`NodeType<enum_XMLParser_NodeType>` | :ref:`get_node_type<class_XMLParser_method_get_node_type>` **(** **)** |
  40. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`has_attribute<class_XMLParser_method_has_attribute>` **(** :ref:`String<class_String>` name **)** |const| |
  42. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_empty<class_XMLParser_method_is_empty>` **(** **)** |const| |
  44. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_XMLParser_method_open>` **(** :ref:`String<class_String>` file **)** |
  46. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open_buffer<class_XMLParser_method_open_buffer>` **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)** |
  48. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`read<class_XMLParser_method_read>` **(** **)** |
  50. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`seek<class_XMLParser_method_seek>` **(** :ref:`int<class_int>` position **)** |
  52. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`skip_section<class_XMLParser_method_skip_section>` **(** **)** |
  54. +------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  55. .. rst-class:: classref-section-separator
  56. ----
  57. .. rst-class:: classref-descriptions-group
  58. Enumerations
  59. ------------
  60. .. _enum_XMLParser_NodeType:
  61. .. rst-class:: classref-enumeration
  62. enum **NodeType**:
  63. .. _class_XMLParser_constant_NODE_NONE:
  64. .. rst-class:: classref-enumeration-constant
  65. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_NONE** = ``0``
  66. There's no node (no file or buffer opened).
  67. .. _class_XMLParser_constant_NODE_ELEMENT:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_ELEMENT** = ``1``
  70. Element (tag).
  71. .. _class_XMLParser_constant_NODE_ELEMENT_END:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_ELEMENT_END** = ``2``
  74. End of element.
  75. .. _class_XMLParser_constant_NODE_TEXT:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_TEXT** = ``3``
  78. Text node.
  79. .. _class_XMLParser_constant_NODE_COMMENT:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_COMMENT** = ``4``
  82. Comment node.
  83. .. _class_XMLParser_constant_NODE_CDATA:
  84. .. rst-class:: classref-enumeration-constant
  85. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_CDATA** = ``5``
  86. CDATA content.
  87. .. _class_XMLParser_constant_NODE_UNKNOWN:
  88. .. rst-class:: classref-enumeration-constant
  89. :ref:`NodeType<enum_XMLParser_NodeType>` **NODE_UNKNOWN** = ``6``
  90. Unknown node.
  91. .. rst-class:: classref-section-separator
  92. ----
  93. .. rst-class:: classref-descriptions-group
  94. Method Descriptions
  95. -------------------
  96. .. _class_XMLParser_method_get_attribute_count:
  97. .. rst-class:: classref-method
  98. :ref:`int<class_int>` **get_attribute_count** **(** **)** |const|
  99. Gets the amount of attributes in the current element.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_XMLParser_method_get_attribute_name:
  103. .. rst-class:: classref-method
  104. :ref:`String<class_String>` **get_attribute_name** **(** :ref:`int<class_int>` idx **)** |const|
  105. Gets the name of the attribute specified by the index in ``idx`` argument.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_XMLParser_method_get_attribute_value:
  109. .. rst-class:: classref-method
  110. :ref:`String<class_String>` **get_attribute_value** **(** :ref:`int<class_int>` idx **)** |const|
  111. Gets the value of the attribute specified by the index in ``idx`` argument.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_XMLParser_method_get_current_line:
  115. .. rst-class:: classref-method
  116. :ref:`int<class_int>` **get_current_line** **(** **)** |const|
  117. Gets the current line in the parsed file (currently not implemented).
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_XMLParser_method_get_named_attribute_value:
  121. .. rst-class:: classref-method
  122. :ref:`String<class_String>` **get_named_attribute_value** **(** :ref:`String<class_String>` name **)** |const|
  123. 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.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_XMLParser_method_get_named_attribute_value_safe:
  127. .. rst-class:: classref-method
  128. :ref:`String<class_String>` **get_named_attribute_value_safe** **(** :ref:`String<class_String>` name **)** |const|
  129. 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.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_XMLParser_method_get_node_data:
  133. .. rst-class:: classref-method
  134. :ref:`String<class_String>` **get_node_data** **(** **)** |const|
  135. Gets the contents of a text node. This will raise an error in any other type of node.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_XMLParser_method_get_node_name:
  139. .. rst-class:: classref-method
  140. :ref:`String<class_String>` **get_node_name** **(** **)** |const|
  141. 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>`.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_XMLParser_method_get_node_offset:
  145. .. rst-class:: classref-method
  146. :ref:`int<class_int>` **get_node_offset** **(** **)** |const|
  147. Gets the byte offset of the current node since the beginning of the file or buffer.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_XMLParser_method_get_node_type:
  151. .. rst-class:: classref-method
  152. :ref:`NodeType<enum_XMLParser_NodeType>` **get_node_type** **(** **)**
  153. Gets the type of the current node. Compare with :ref:`NodeType<enum_XMLParser_NodeType>` constants.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_XMLParser_method_has_attribute:
  157. .. rst-class:: classref-method
  158. :ref:`bool<class_bool>` **has_attribute** **(** :ref:`String<class_String>` name **)** |const|
  159. Check whether the current element has a certain attribute.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_XMLParser_method_is_empty:
  163. .. rst-class:: classref-method
  164. :ref:`bool<class_bool>` **is_empty** **(** **)** |const|
  165. Check whether the current element is empty (this only works for completely empty tags, e.g. ``<element \>``).
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_XMLParser_method_open:
  169. .. rst-class:: classref-method
  170. :ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` file **)**
  171. Opens an XML file for parsing. This returns an error code.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_XMLParser_method_open_buffer:
  175. .. rst-class:: classref-method
  176. :ref:`Error<enum_@GlobalScope_Error>` **open_buffer** **(** :ref:`PoolByteArray<class_PoolByteArray>` buffer **)**
  177. Opens an XML raw buffer for parsing. This returns an error code.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_XMLParser_method_read:
  181. .. rst-class:: classref-method
  182. :ref:`Error<enum_@GlobalScope_Error>` **read** **(** **)**
  183. Reads the next node of the file. This returns an error code.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_XMLParser_method_seek:
  187. .. rst-class:: classref-method
  188. :ref:`Error<enum_@GlobalScope_Error>` **seek** **(** :ref:`int<class_int>` position **)**
  189. Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_XMLParser_method_skip_section:
  193. .. rst-class:: classref-method
  194. void **skip_section** **(** **)**
  195. 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.
  196. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  197. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  198. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  199. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`