How to prevent namespace insertion when calling Node.toString?

I’m using Scala’s XPath-like syntax to extract a part of an XML document. Once I find the node I’m looking for, I call toString() on that node in order to get the node’s string representation. However, it seems that the method forcefully inserts the document’s xmlns entries into the node as attributes.

I could manually remove the xmlns entries but it feels like a hack. Is there a proper way to prevent them from being inserted in the first place?

Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.