Merge pull request #3380 from greyanubis/devel
Add proc to change an element tag and proc to insert xmlnode child
This commit is contained in:
commit
52342a11f6
1 changed files with 13 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue