summaryrefslogtreecommitdiff
path: root/doc/classes/XMLParser.xml
blob: 1e041b9baa162585794d48a369abd54163506684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="UTF-8" ?>
<class name="XMLParser" inherits="Reference" category="Core" version="3.2">
	<brief_description>
		Low-level class for creating parsers for [url=https://en.wikipedia.org/wiki/XML]XML[/url] files.
	</brief_description>
	<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.
	</description>
	<tutorials>
	</tutorials>
	<methods>
		<method name="get_attribute_count" qualifiers="const">
			<return type="int">
			</return>
			<description>
				Gets the amount of attributes in the current element.
			</description>
		</method>
		<method name="get_attribute_name" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Gets the name of the attribute specified by the index in [code]idx[/code] argument.
			</description>
		</method>
		<method name="get_attribute_value" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="idx" type="int">
			</argument>
			<description>
				Gets the value of the attribute specified by the index in [code]idx[/code] argument.
			</description>
		</method>
		<method name="get_current_line" qualifiers="const">
			<return type="int">
			</return>
			<description>
				Gets the current line in the parsed file (currently not implemented).
			</description>
		</method>
		<method name="get_named_attribute_value" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<description>
				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.
			</description>
		</method>
		<method name="get_named_attribute_value_safe" qualifiers="const">
			<return type="String">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<description>
				Gets the value of a certain attribute of the current element by name. This will return an empty [String] if the attribute is not found.
			</description>
		</method>
		<method name="get_node_data" qualifiers="const">
			<return type="String">
			</return>
			<description>
				Gets the contents of a text node. This will raise an error in any other type of node.
			</description>
		</method>
		<method name="get_node_name" qualifiers="const">
			<return type="String">
			</return>
			<description>
				Gets the name of the current element node. This will raise an error if the current node type is neither [constant NODE_ELEMENT] nor [constant NODE_ELEMENT_END].
			</description>
		</method>
		<method name="get_node_offset" qualifiers="const">
			<return type="int">
			</return>
			<description>
				Gets the byte offset of the current node since the beginning of the file or buffer.
			</description>
		</method>
		<method name="get_node_type">
			<return type="int" enum="XMLParser.NodeType">
			</return>
			<description>
				Gets the type of the current node. Compare with [enum NodeType] constants.
			</description>
		</method>
		<method name="has_attribute" qualifiers="const">
			<return type="bool">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<description>
				Check whether the current element has a certain attribute.
			</description>
		</method>
		<method name="is_empty" qualifiers="const">
			<return type="bool">
			</return>
			<description>
				Check whether the current element is empty (this only works for completely empty tags, e.g. [code]&lt;element \&gt;[/code]).
			</description>
		</method>
		<method name="open">
			<return type="int" enum="Error">
			</return>
			<argument index="0" name="file" type="String">
			</argument>
			<description>
				Opens an XML file for parsing. This returns an error code.
			</description>
		</method>
		<method name="open_buffer">
			<return type="int" enum="Error">
			</return>
			<argument index="0" name="buffer" type="PoolByteArray">
			</argument>
			<description>
				Opens an XML raw buffer for parsing. This returns an error code.
			</description>
		</method>
		<method name="read">
			<return type="int" enum="Error">
			</return>
			<description>
				Reads the next node of the file. This returns an error code.
			</description>
		</method>
		<method name="seek">
			<return type="int" enum="Error">
			</return>
			<argument index="0" name="position" type="int">
			</argument>
			<description>
				Moves the buffer cursor to a certain offset (since the beginning) and read the next node there. This returns an error code.
			</description>
		</method>
		<method name="skip_section">
			<return type="void">
			</return>
			<description>
				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.
			</description>
		</method>
	</methods>
	<constants>
		<constant name="NODE_NONE" value="0" enum="NodeType">
			There's no node (no file or buffer opened).
		</constant>
		<constant name="NODE_ELEMENT" value="1" enum="NodeType">
			Element (tag).
		</constant>
		<constant name="NODE_ELEMENT_END" value="2" enum="NodeType">
			End of element.
		</constant>
		<constant name="NODE_TEXT" value="3" enum="NodeType">
			Text node.
		</constant>
		<constant name="NODE_COMMENT" value="4" enum="NodeType">
			Comment node.
		</constant>
		<constant name="NODE_CDATA" value="5" enum="NodeType">
			CDATA content.
		</constant>
		<constant name="NODE_UNKNOWN" value="6" enum="NodeType">
			Unknown node.
		</constant>
	</constants>
</class>