IXMLDocument exclude xml declaration
Asked Answered
H

1

8

I am trying to get xml text from an IXMLDocument like so.

Doc.XML.Text;

This gives me the xml text but it includes the xml declaration.

<?xml version="1.0"?>

Is there a way I can get the xml text excluding the xml declaration. I could always remove it manually myself from the string result, but I feel like there should be property or something which I can set on the document to exclude the xml declaration.

Example

Doc.XML.Text outputs

<?xml version="1.0"?>
<Certificates>
  <Certificate>
  </Certificate>
</Certificates>
Hemihedral answered 22/1, 2014 at 22:27 Comment(5)
Read it from Doc.DocumentElement.XML instead.Stowers
@Stowers that does work, but it excludes the first tag from the xml as well.Hemihedral
It shouldn't be, since DocumentElement points at the <Certificates> node, and asking a node for its XML is supposed to include that node in the output.Quadrillion
@Stowers Doc.DocumentElement.XML is the answerHemihedral
I tested it, DocumentElement.XML works fine.Quadrillion
S
9

You can read it from the DocumentElement.XML property. The DocumentElement property provides access to the root node of the XML document and XML returns the XML content of a node.

Stowers answered 22/1, 2014 at 22:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.