Skip to content

Commit a87831e

Browse files
committed
fix readme example
1 parent 7ec50de commit a87831e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,22 @@ node["key"] = value
9999
node["key"]
100100
```
101101

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 copy with one or more field values changed by using the `Node(::Node, children...; attrs...)` constructor where `children` are appended to the source node's children and `attrs` are appended to the node's attributes.
103103

104104
```julia
105105
node = XML.Element("tag", XML.Text("child"))
106+
# Node Element <tag> (1 child)
106107

107108
simple_value(node)
108109
# "child"
109110

110-
node2 = Node(node, children=XML.Text("changed"))
111+
node2 = Node(node, "added"; id="my-id")
112+
# Node Element <tag id="my-id"> (2 children)
111113

112-
simple_value(node2)
113-
# "changed"
114+
node2.children
115+
# 2-element Vector{Node}:
116+
# Node Text "child"
117+
# Node Text "added"
114118
```
115119

116120
### Writing `Element` `Node`s with `XML.h`

0 commit comments

Comments
 (0)