added xmltree.innerText; fixes #49
This commit is contained in:
parent
c6038dda04
commit
2183bf77a6
7 changed files with 114 additions and 33 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -71,6 +71,15 @@ proc text*(n: PXmlNode): string {.inline.} =
|
|||
assert n.k in {xnText, xnComment, xnCData, xnEntity}
|
||||
result = n.fText
|
||||
|
||||
proc innerText*(n: PXmlNode): string =
|
||||
## gets the inner text of `n`. `n` has to be an ``xnElement`` node. Only
|
||||
## ``xnText`` and ``xnEntity`` nodes are considered part of `n`'s inner text,
|
||||
## other child nodes are silently ignored.
|
||||
result = ""
|
||||
assert n.k == xnElement
|
||||
for i in 0 .. n.s.len-1:
|
||||
if n.s[i].k in {xnText, xnEntity}: result.add(n.fText)
|
||||
|
||||
proc tag*(n: PXmlNode): string {.inline.} =
|
||||
## gets the tag name of `n`. `n` has to be an ``xnElement`` node.
|
||||
assert n.k == xnElement
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue