added proc to change an element tag and proc to insert xmlnode child

This commit is contained in:
sergey.anufriev
2015-09-26 09:57:07 +06:00
parent 9352772174
commit 64737c8496

View File

@@ -104,10 +104,23 @@ proc tag*(n: XmlNode): string {.inline.} =
assert n.k == xnElement
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.} =
## adds the child `son` to `father`.
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.} =
## returns the number `n`'s children.
if n.k == xnElement: result = len(n.s)