Nim
Nim copied to clipboard
add elemText proc to xmltree
text*
proc cannot be used with an xnElement type.
elemText*
is intended to fill that gap.
This proc gets the associated text for an element node n
. Finds all the top level text nodes for an element
and returns a concatenated string of their contents. An optional string can be passed to be used as a text node separator.
If there are no text nodes, an empty string is returned.
I didn't check the PR in detail, but how is this different from xmltree.innerText
- https://nim-lang.org/docs/xmltree.html#innerText%2CXmlNode?
innerText
does all nodes with an fText
property and ripples through all the child nodes of a node.
elemText
only does the top level xnText
's nodes for only an xnElement
. AFAIK there is no equivalent proc in the xmltree
library.
Mr Rumpf didn't like my last effort but left instructions as to what would be acceptable. Check the closed PR here
Just curious, do other language's XML libraries have an equivalent to this? If so, what is it called?
plainText
or stripTags
would be better names.
it's like innerText
and textContent
in html
If in doubt, leave it out. These things never exactly do what you need anyway and you're better off with custom logic instead.