From f405876b35b4ff4f95dcd289bd51df196aab5569 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 7 Sep 2015 12:25:53 +0600 Subject: [PATCH 1/2] add text modification proc --- lib/pure/xmltree.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 4269a3e48..435a7a549 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -74,6 +74,12 @@ proc text*(n: XmlNode): string {.inline.} = assert n.k in {xnText, xnComment, xnCData, xnEntity} result = n.fText +proc `text=`*(n: XmlNode, text: string){.inline.} = + ## sets the associated text with the node `n`. `n` can be a CDATA, Text, + ## comment, or entity node. + assert n.k in {xnText, xnComment, xnCData, xnEntity} + n.fText = text + proc rawText*(n: XmlNode): string {.inline.} = ## returns the underlying 'text' string by reference. ## This is only used for speed hacks. From a5344340569b0b54351f902a79b2d1f8f2397dc6 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 7 Sep 2015 21:19:52 +0600 Subject: [PATCH 2/2] allow to delete xmlnode childs --- lib/pure/xmltree.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 435a7a549..1c8573986 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -121,6 +121,11 @@ proc `[]`* (n: XmlNode, i: int): XmlNode {.inline.} = assert n.k == xnElement result = n.s[i] +proc delete*(n: XmlNode, i: Natural) {.noSideEffect.} = + ## delete the `i`'th child of `n`. + assert n.k == xnElement + n.s.delete(i) + proc mget* (n: var XmlNode, i: int): var XmlNode {.inline.} = ## returns the `i`'th child of `n` so that it can be modified assert n.k == xnElement