summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-10-07 09:26:01 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-10-07 09:26:01 +0200
commit52342a11f6e413646a504a77587108398881a28a (patch)
tree13ac92b14be53931fdfb5e45fb101a6f9c3ea890 /lib/pure
parent80ee72956af12b54853bfe05c1bd3fd3e47ff052 (diff)
parent64737c8496e5984336307e7a2dca18aed3c5b227 (diff)
downloadNim-52342a11f6e413646a504a77587108398881a28a.tar.gz
Merge pull request #3380 from greyanubis/devel
Add proc to change an element tag and proc to insert xmlnode child
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/xmltree.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim
index 1c8573986..7c97a0a56 100644
--- a/lib/pure/xmltree.nim
+++ b/lib/pure/xmltree.nim
@@ -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)