[Gambas-user] Multiple top-level nodes with XmlDocument

Tobias Boege taboege at ...626...
Sat Apr 8 17:23:32 CEST 2017


Hi,

I want to write an XML file like this:

  <?xml version="1.0" encoding="utf-8" ?>
  <!-- Introductory comment -->
  <tag />

Note that I have a comment node and an element node at the top-level of the
DOM tree. This [1] gives me the impression that it should be valid XML.

This is straight forward with XmlWriter, but it doesn't seem possible with
XmlDocument since it allows for only one Root node. XmlDocument.Root is an
XmlElement and consequently always renders as

  <RootName>
    ...
  </RootName>

which can even produce

  <>
  </>

in the output XML file if you set XmlDocument.Root.Name = Null.

Regards,
Tobi

[1] http://stackoverflow.com/questions/14726276/what-is-the-root-node-in-xml

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list