added proc to change an element tag and proc to insert xmlnode child
This commit is contained in:
parent
9352772174
commit
64737c8496
1 changed files with 13 additions and 0 deletions
|
|
@ -104,10 +104,23 @@ proc tag*(n: XmlNode): string {.inline.} =
|
||||||
assert n.k == xnElement
|
assert n.k == xnElement
|
||||||
result = n.fTag
|
result = n.fTag
|
||||||
|
|
||||||
|
proc `tag=`*(n: XmlNode, tag: string) {.inline.} =
|
||||||
|
## sets the tag name of `n`. `n` has to be an ``xnElement`` node.
|
||||||
|
assert n.k == xnElement
|
||||||
|
n.fTag = tag
|
||||||
|
|
||||||
proc add*(father, son: XmlNode) {.inline.} =
|
proc add*(father, son: XmlNode) {.inline.} =
|
||||||
## adds the child `son` to `father`.
|
## adds the child `son` to `father`.
|
||||||
add(father.s, son)
|
add(father.s, son)
|
||||||
|
|
||||||
|
proc insert*(father, son: XmlNode, index: int) {.inline.} =
|
||||||
|
## insert the child `son` to a given position in `father`.
|
||||||
|
assert father.k == xnElement and son.k == xnElement
|
||||||
|
if len(father.s) > index:
|
||||||
|
insert(father.s, son, index)
|
||||||
|
else:
|
||||||
|
insert(father.s, son, len(father.s))
|
||||||
|
|
||||||
proc len*(n: XmlNode): int {.inline.} =
|
proc len*(n: XmlNode): int {.inline.} =
|
||||||
## returns the number `n`'s children.
|
## returns the number `n`'s children.
|
||||||
if n.k == xnElement: result = len(n.s)
|
if n.k == xnElement: result = len(n.s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue