forked from ortuman/jackal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutable_element.go
81 lines (65 loc) · 1.98 KB
/
mutable_element.go
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
/*
* Copyright (c) 2018 Miguel Ángel Ortuño.
* See the LICENSE file for more information.
*/
package xmpp
// SetName sets XML node name.
func (e *Element) SetName(name string) {
e.name = name
}
// SetAttribute sets an XML node attribute (label=value)
func (e *Element) SetAttribute(label, value string) {
e.attrs.setAttribute(label, value)
}
// RemoveAttribute removes an XML node attribute.
func (e *Element) RemoveAttribute(label string) {
e.attrs.removeAttribute(label)
}
// AppendElement appends a new sub element.
func (e *Element) AppendElement(element XElement) {
e.elements.append(element)
}
// AppendElements appends an array of sub elements.
func (e *Element) AppendElements(elements []XElement) {
e.elements.append(elements...)
}
// RemoveElements removes all elements with a given name.
func (e *Element) RemoveElements(name string) {
e.elements.remove(name)
}
// RemoveElementsNamespace removes all elements with a given name and namespace.
func (e *Element) RemoveElementsNamespace(name, namespace string) {
e.elements.removeNamespace(name, namespace)
}
// SetNamespace sets 'xmlns' node attribute.
func (e *Element) SetNamespace(namespace string) {
e.attrs.setAttribute("xmlns", namespace)
}
// ClearElements removes all elements.
func (e *Element) ClearElements() {
e.elements.clear()
}
// SetText sets XML node text value.
func (e *Element) SetText(text string) {
e.text = text
}
// SetID sets 'id' node attribute.
func (e *Element) SetID(identifier string) {
e.attrs.setAttribute("id", identifier)
}
// SetLanguage sets 'xml:lang' node attribute.
func (e *Element) SetLanguage(language string) {
e.attrs.setAttribute("xml:lang", language)
}
// SetFrom sets 'from' node attribute.
func (e *Element) SetFrom(from string) {
e.attrs.setAttribute("from", from)
}
// SetTo sets 'to' node attribute.
func (e *Element) SetTo(to string) {
e.attrs.setAttribute("to", to)
}
// SetType sets 'type' node attribute.
func (e *Element) SetType(tp string) {
e.attrs.setAttribute("type", tp)
}