omitXMLDeclaration Property

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Reference

omitXMLDeclaration Property

Forces the MXXMLWriter to omit the XML declaration. This property can be used to output fragments of larger XML documents that can be assembled into a single XML document later.

[Visual Basic]

Usage Syntax

oMXXMLWriter.omitXMLDeclaration= boolValue
boolValue = oMXXMLWriter.omitXMLDeclaration

Remarks

Boolean. Read/write.

Example

The following example parses books.xml and generates an XML document without the XML declaration.

Dim rdr As New Msxml2.SAXXMLReader50
Dim cnth As IVBSAXContentHandler
Dim wrt As New MXXMLWriter50
wrt.indent = True
wrt.omitXMLDeclaration = True
wrt.byteOrderMark = False
Set cnth = wrt
Set rdr.contentHandler = cnth
rdr.parseURL ("books.xml")
MsgBox wrt.output

Results

The following shows a fragment of books.xml with the XML declaration omitted from the output.

<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <release_years>1998 2000</release_years>
      <description>An in-depth look at creating applications with XML.</description>
   </book>
[C/C++]

Syntax

[propput]
HRESULT omitXMLDeclaration (
   [in] VARIANT_BOOL fValue);
[propget]
HRESULT omitXMLDeclaration (
   [out, retval] VARIANT_BOOL * fValue);

Parameters

fValue
Boolean. Read/write.

Return Values

S_OK
The value returned if no errors are reported.

Remarks

Value Description
True Omit XML declaration.
False (default) Provide XML declaration.

To view reference material for Visual Basic or C++ only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Sample XML File (books.xml)

Applies to: MXXMLWriter CoClass