class_xmlparser.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the XMLParser.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_XMLParser:
  5. XMLParser
  6. =========
  7. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Low-level class for creating parsers for XML files.
  12. Member Functions
  13. ----------------
  14. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_attribute_count<class_XMLParser_get_attribute_count>` **(** **)** const |
  16. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`String<class_string>` | :ref:`get_attribute_name<class_XMLParser_get_attribute_name>` **(** :ref:`int<class_int>` idx **)** const |
  18. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`String<class_string>` | :ref:`get_attribute_value<class_XMLParser_get_attribute_value>` **(** :ref:`int<class_int>` idx **)** const |
  20. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`int<class_int>` | :ref:`get_current_line<class_XMLParser_get_current_line>` **(** **)** const |
  22. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`String<class_string>` | :ref:`get_named_attribute_value<class_XMLParser_get_named_attribute_value>` **(** :ref:`String<class_string>` name **)** const |
  24. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`String<class_string>` | :ref:`get_named_attribute_value_safe<class_XMLParser_get_named_attribute_value_safe>` **(** :ref:`String<class_string>` name **)** const |
  26. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`String<class_string>` | :ref:`get_node_data<class_XMLParser_get_node_data>` **(** **)** const |
  28. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`String<class_string>` | :ref:`get_node_name<class_XMLParser_get_node_name>` **(** **)** const |
  30. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_node_offset<class_XMLParser_get_node_offset>` **(** **)** const |
  32. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`get_node_type<class_XMLParser_get_node_type>` **(** **)** |
  34. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`has_attribute<class_XMLParser_has_attribute>` **(** :ref:`String<class_string>` name **)** const |
  36. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`is_empty<class_XMLParser_is_empty>` **(** **)** const |
  38. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`open<class_XMLParser_open>` **(** :ref:`String<class_string>` file **)** |
  40. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`open_buffer<class_XMLParser_open_buffer>` **(** :ref:`PoolByteArray<class_poolbytearray>` buffer **)** |
  42. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`read<class_XMLParser_read>` **(** **)** |
  44. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`seek<class_XMLParser_seek>` **(** :ref:`int<class_int>` position **)** |
  46. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`skip_section<class_XMLParser_skip_section>` **(** **)** |
  48. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  49. Enums
  50. -----
  51. .. _enum_XMLParser_NodeType:
  52. enum **NodeType**
  53. - **NODE_NONE** = **0** --- There's no node (no file or buffer opened)
  54. - **NODE_ELEMENT** = **1** --- Element (tag)
  55. - **NODE_ELEMENT_END** = **2** --- End of element
  56. - **NODE_TEXT** = **3** --- Text node
  57. - **NODE_COMMENT** = **4** --- Comment node
  58. - **NODE_CDATA** = **5** --- CDATA content
  59. - **NODE_UNKNOWN** = **6** --- Unknown node
  60. Description
  61. -----------
  62. 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.
  63. Member Function Description
  64. ---------------------------
  65. .. _class_XMLParser_get_attribute_count:
  66. - :ref:`int<class_int>` **get_attribute_count** **(** **)** const
  67. Get the amount of attributes in the current element.
  68. .. _class_XMLParser_get_attribute_name:
  69. - :ref:`String<class_string>` **get_attribute_name** **(** :ref:`int<class_int>` idx **)** const
  70. Get the name of the attribute specified by the index in ``idx`` argument.
  71. .. _class_XMLParser_get_attribute_value:
  72. - :ref:`String<class_string>` **get_attribute_value** **(** :ref:`int<class_int>` idx **)** const
  73. Get the value of the attribute specified by the index in ``idx`` argument.
  74. .. _class_XMLParser_get_current_line:
  75. - :ref:`int<class_int>` **get_current_line** **(** **)** const
  76. Get the current line in the parsed file (currently not implemented).
  77. .. _class_XMLParser_get_named_attribute_value:
  78. - :ref:`String<class_string>` **get_named_attribute_value** **(** :ref:`String<class_string>` name **)** const
  79. 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.
  80. .. _class_XMLParser_get_named_attribute_value_safe:
  81. - :ref:`String<class_string>` **get_named_attribute_value_safe** **(** :ref:`String<class_string>` name **)** const
  82. Get 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.
  83. .. _class_XMLParser_get_node_data:
  84. - :ref:`String<class_string>` **get_node_data** **(** **)** const
  85. Get the contents of a text node. This will raise an error in any other type of node.
  86. .. _class_XMLParser_get_node_name:
  87. - :ref:`String<class_string>` **get_node_name** **(** **)** const
  88. Get the name of the current element node. This will raise an error if the current node type is not ``NODE_ELEMENT`` nor ``NODE_ELEMENT_END``
  89. .. _class_XMLParser_get_node_offset:
  90. - :ref:`int<class_int>` **get_node_offset** **(** **)** const
  91. Get the byte offset of the current node since the beginning of the file or buffer.
  92. .. _class_XMLParser_get_node_type:
  93. - :ref:`int<class_int>` **get_node_type** **(** **)**
  94. Get the type of the current node. Compare with ``NODE_*`` constants.
  95. .. _class_XMLParser_has_attribute:
  96. - :ref:`bool<class_bool>` **has_attribute** **(** :ref:`String<class_string>` name **)** const
  97. Check whether or not the current element has a certain attribute.
  98. .. _class_XMLParser_is_empty:
  99. - :ref:`bool<class_bool>` **is_empty** **(** **)** const
  100. Check whether the current element is empty (this only works for completely empty tags, e.g. <element \>).
  101. .. _class_XMLParser_open:
  102. - :ref:`int<class_int>` **open** **(** :ref:`String<class_string>` file **)**
  103. Open a XML file for parsing. This returns an error code.
  104. .. _class_XMLParser_open_buffer:
  105. - :ref:`int<class_int>` **open_buffer** **(** :ref:`PoolByteArray<class_poolbytearray>` buffer **)**
  106. Open a XML raw buffer for parsing. This returns an error code.
  107. .. _class_XMLParser_read:
  108. - :ref:`int<class_int>` **read** **(** **)**
  109. Read the next node of the file. This returns an error code.
  110. .. _class_XMLParser_seek:
  111. - :ref:`int<class_int>` **seek** **(** :ref:`int<class_int>` position **)**
  112. Move the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
  113. .. _class_XMLParser_skip_section:
  114. - void **skip_section** **(** **)**
  115. 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.