Text portion of an XmlNode type

2022-08-04 Thread Araq
> This looks like the original author knew this was a problem, guarded against > it, but never came back to fix it. Not quite, I realized a more complete solution goes into the realms of custom application logic.

Text portion of an XmlNode type

2022-08-03 Thread LaughingBubba
So I found the problem which was: the `text*` getter was incomplete. All node kinds (other than `xnElement`) have an `fText` property. That's why there was as guard assertion in place which is what was causing the crash as I was trying to get the text of an `xnElement`. `xnElement` stores it's

Text portion of an XmlNode type

2022-08-02 Thread LaughingBubba
I had considered the same work around. However the purpose of the [`text`](https://nim-lang.org/docs/xmltree.html#text%2CXmlNode) proc is stated as: "Gets the associated text with the node `n`" TBH I would rather spend a week trying to figure out how to fix `xmltree` and submit a PR than code a

Text portion of an XmlNode type

2022-08-01 Thread pietroppeter
You can build your own proc that only returns text from children of kind xnText: import xmltree var e = newElement("child1") e.add newText(" jibber") var f = newElement("child2") f.add newText(" jabber") var x = newXmlTree("root", [e, f]) x.add n

Text portion of an XmlNode type

2022-08-01 Thread LaughingBubba
I opted against `innerText` because it does indeed return the text of the node and all it's children: import xmltree var e = newElement("child1") e.add newText(" jibber") var f = newElement("child2") f.add newText(" jabber") var x = newXmlTree("root

Text portion of an XmlNode type

2022-08-01 Thread pietroppeter
to access text content of a generic `XmlNode` you can use [innerText](https://nim-lang.org/docs/xmltree.html#innerText%2CXmlNode). The node you create is not of kind `xnText` and so it does not have a `text` attribute. It does have a child (it can have multiple children), which is of kind `xnTe

Text portion of an XmlNode type

2022-08-01 Thread LaughingBubba
ionDefect] Error: execution of an external program failed: /Users/_/Projects/my-nim/src/x Run It looks like you can't directly access the text portion of an XmlNode type. Have I misread the docs or is there something else going on? Thanks PS: macos arm64 FWIW