You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-7Lines changed: 39 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,20 +99,52 @@ node["key"] = value
99
99
node["key"]
100
100
```
101
101
102
-
-`Node` is an immutable type. However, you can easily create a copy with one or more field values changed by using the `Node(::Node; kw...)` constructor where `kw` are the fields you want to change. For example:
102
+
-`Node` is an immutable type. However, you can easily create a simple copy using `copy(::Node)` or
103
+
copy with one or more changes by using the `Node(::Node, atts...; kw...)` constructor where `atts`
104
+
are new children to add and `kw` are the node attributes you want to add or change. For example:
julia> node3 =Node(node2, XML.Element("new_child", child_att="I'm new too"))
117
+
Node Element <tag new_att="I'm new"> (2 children)
118
+
119
+
julia>println(XML.write(node))
120
+
<tag>child</tag>
121
+
122
+
julia>println(XML.write(node2))
123
+
<tag new_att="I'm new">child</tag>
124
+
125
+
julia>println(XML.write(node3))
126
+
<tag new_att="I'm new">
127
+
child
128
+
<new_child child_att="I'm new too"/>
129
+
</tag>
130
+
131
+
julia> node4=copy(node3)
132
+
Node Element <tag new_att="I'm new"> (2 children)
133
+
134
+
julia>println(XML.write(node4))
135
+
<tag new_att="I'm new">
136
+
child
137
+
<new_child child_att="I'm new too"/>
138
+
</tag>
139
+
140
+
julia> node4==node3
141
+
true
142
+
143
+
julia> node4===node3
144
+
false
114
145
```
115
146
147
+
116
148
### Writing `Element``Node`s with `XML.h`
117
149
118
150
Similar to [Cobweb.jl](https://github.com/JuliaComputing/Cobweb.jl#-creating-nodes-with-cobwebh), `XML.h` enables you to write elements with a simpler syntax:
0 commit comments