aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/jsextensions/jsextension-xml.qdoc
blob: b5d3891aefbe427cf9ea137d03a27e174e73f4b1 (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \contentspage index.html
    \page jsextension-xml.html
    \ingroup list-of-builtin-services

    \title Xml Service
    \brief Provides a DOM parser and generator to JavaScript.

    The \c Xml service enables you to access and manipulate XML Document
    Object Model (DOM) documents. The entire document is a \e {document node},
    each XML element is an \e {element node}, the text paragraphs in the XML
    elements are \e {text nodes}, and each attribute is an \e {attribute node}.

    XML DOM presents documents as tree structures. The contents of the nodes
    can be accessed in the tree. They can be modified or deleted, and new
    nodes can be created.

    The nodes in the node tree have a hierarchical relationship to each other.
    The top node is called the \e root. Each node, except the root, has exactly
    one \e parent node, while it can have any number of \e children. Nodes with
    the same parent are called \e siblings.

    \section1 XML DOM Document Node Operations

    A document node represents an entire document. That is, the root of the DOM
    tree.

    \section2 Constructor

    \badcode
    Xml.DomDocument()
    \endcode

    Creates an XML DOM root node that can contain one element.

    \section2 createCDATASection

    \badcode
    Xml.DomDocument.createCDATASection(value: string)
    \endcode

    Creates a CDATA section that is not parsed by a parser. It can be used to
    include XML fragments without having to escape the delimiters, for example.
    Tags inside the section are not treated as markup nor are entities expanded.

    \section2 createElement

    \badcode
    Xml.DomDocument.createElement(tagName: string)
    \endcode

    Creates an element that can contain other elements, CDATA sections, and text
    nodes.

    \section2 createTextNode

    \badcode
    Xml.DomDocument.createTextNode(value: string)
    \endcode

    Creates a text node that represents textual content in an element or
    attribute.

    \section2 documentElement

    \badcode
    Xml.DomDocument.documentElement()
    \endcode

    Returns the document element.

    \section2 load

    \badcode
    Xml.DomDocument.load(filePath: string): void
    \endcode

    Loads the document specified by \c filePath.

    \section2 save

    \badcode
    Xml.DomDocument.save(filePath: string, indentation: int): void
    \endcode

    Saves the document at the location specified by \c filePath with the
    indentation specified by \c int.

    \section2 setContent

    \badcode
    Xml.DomDocument.setContent(content: string)
    \endcode

    Returns the content of the document.

    \section2 toString

    \badcode
    Xml.DomDocument.toString(indentation: int)
    \endcode

    Converts the document to a string with the indentation specified by \c int.

    \section1 XML DOM Node Operations

    A node represents a single node in the document tree. There are several
    different types of nodes, such as element, attribute, and text nodes.

    All objects inherit the node properties for handling parents and children,
    even if they cannot have parents or children. For example, attempting to add
    children to text nodes results in a DOM error.

    \section2 Constructor

    \badcode
    Xml.DomNode()
    \endcode

    Creates an XML DOM node.

    \section2 appendChild

    \badcode
    Xml.DomNode.appendChild(tagName: string)
    \endcode

    Appends a new child node to the end of the list of children of a node.

    \section2 attribute

    \badcode
    Xml.DomNode.attribute(name: string, defaultValue: string)
    \endcode

    Returns the name and default value of the attribute.

    \section2 clear

    \badcode
    Xml.DomNode.clear()
    \endcode

    Clears the contents of the node.

    \section2 data

    \badcode
    Xml.DomNode.data()
    \endcode

    Returns the contents of the text node, CDATA section, or character data
    node.

    \section2 firstChild

    \badcode
    Xml.DomNode.firstChild(tagName: string)
    \endcode

    Returns the first child of a node.

    \section2 hasAttribute

    \badcode
    Xml.DomNode.hasAttribute(name: string) boolean
    \endcode

    Returns \c true if the node has the specified attribute.

    \section2 hasAttributes

    \badcode
    Xml.DomNode.hasAttributes() boolean
    \endcode

    Returns \c true if the node has attributes.

    \section2 hasChildNodes

    \badcode
    Xml.DomNode.hasChildNodes() boolean
    \endcode

    Returns \c true if the node has children.

    \section2 insertAfter

    \badcode
    Xml.DomNode.insertAfter(newChild: tagName, refChild: tagName)
    \endcode

    Inserts a new child node after the child node specified by \c refChild.

    \section2 insertBefore

    \badcode
    Xml.DomNode.insertBefore(newChild: tagName, refChild: tagName)
    \endcode

    Inserts a new child node before the child node specified by \c refChild.

    \section2 isCDATASection

    \badcode
    Xml.DomNode.isCDATASection() boolean
    \endcode

    Returns \c true if this is a CDATA section.

    \section2 isElement

    \badcode
    Xml.DomNode.isElement() boolean
    \endcode

    Returns \c true if this is an element.

    \section2 isText

    \badcode
    Xml.DomNode.isText() boolean
    \endcode

    Returns \c true if this is a text node.

    \section2 lastChild

    \badcode
    Xml.DomNode.lastChild(tagName: string)
    \endcode

    Returns the last child of a node.

    \section2 nextSibling

    \badcode
    Xml.DomNode.nextSibling(tagName: string)
    \endcode

    Returns the node immediately following a node.

    \section2 parentNode

    \badcode
    Xml.DomNode.parentNode()
    \endcode

    Returns the parent of the node.

    \section2 previousSibling

    \badcode
    Xml.DomNode.previousSibling(tagName: string)
    \endcode

    Returns the node before a node.

    \section2 removeChild

    \badcode
    Xml.DomNode.removeChild(tagName: string)
    \endcode

    Removes the child node.

    \section2 replaceChild

    \badcode
    Xml.DomNode.replaceChild(newChild: tagName, oldChild: tagName)
    \endcode

    Replaces a child node with another one.

    \section2 setAttribute

    \badcode
    Xml.DomNode.setAttribute(name: string, value: string)
    \endcode

    Sets the name and value of an attribute.

    \section2 setData

    \badcode
    Xml.DomNode.setData(value: string): void
    \endcode

    Sets the data of the node to a text node, CDATA section, or character data
    node.

    \section2 setTagName

    \badcode
    Xml.DomNode.setTagName(tagName: string)
    \endcode

    Sets the tag name of the node.

    \section2 tagName

    \badcode
    Xml.DomNode.tagName()
    \endcode

    Returns the tag name of the node.

    \section2 text

    \badcode
    Xml.DomNode.text()
    \endcode

    Returns the text of the node.
*/