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 `xnText`. Compare your code with the [following](https://play.nim-lang.org/#ix=46lC): import xmltree var e = newElement("elem") e.add newText("some text") echo typeof e echo e.kind echo e echo e.innerText e.add newText(" and other text") echo e.innerText echo "" var f = newText("some text") echo typeof f echo f.kind echo f.text Run output: XmlNode xnElement <elem>some text</elem> some text some text and other text XmlNode xnText some text Run