class_xmlparser.rst 10 KB

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