Clean up (as suggested by @Araq)
This commit is contained in:
parent
6bd86f7543
commit
ff69656f80
1 changed files with 5 additions and 6 deletions
|
|
@ -97,19 +97,18 @@ proc innerText*(n: XmlNode): string =
|
||||||
## - If `n` is `xnElement`, runs recursively on each child node and
|
## - If `n` is `xnElement`, runs recursively on each child node and
|
||||||
## concatenates the results.
|
## concatenates the results.
|
||||||
## - Otherwise returns an empty string.
|
## - Otherwise returns an empty string.
|
||||||
var res = ""
|
proc worker(res: var string, n: XmlNode) =
|
||||||
proc worker(n: XmlNode) =
|
|
||||||
case n.k
|
case n.k
|
||||||
of { xnText, xnEntity }:
|
of xnText, xnEntity:
|
||||||
res.add(n.fText)
|
res.add(n.fText)
|
||||||
of xnElement:
|
of xnElement:
|
||||||
for sub in n.s:
|
for sub in n.s:
|
||||||
worker(sub)
|
worker(res, sub)
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
worker(n)
|
result = ""
|
||||||
res
|
worker(result, n)
|
||||||
|
|
||||||
proc tag*(n: XmlNode): string {.inline.} =
|
proc tag*(n: XmlNode): string {.inline.} =
|
||||||
## gets the tag name of `n`. `n` has to be an ``xnElement`` node.
|
## gets the tag name of `n`. `n` has to be an ``xnElement`` node.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue