indent Property

MSXML 5.0 SDK

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

indent Property

Sets whether to indent output. When set to True, this property requires output to be indented (or "pretty printed") to reflect the nesting structure of the document.

[Visual Basic]

Usage Syntax

oMXXMLWriter.indent = boolValue
boolValue = oMXXMLWriter.indent

Remarks

Boolean. Read/write. The general rules of indentation are: XML headers and root elements start on a new line with a zero indent; element content, including leading and trailing white spaces, is not changed in any way.

Example

The following example creates a simple HTML document and indents it for "pretty-printing."

Dim wrt As New MXHTMLWriter50
Dim cnth As IVBSAXContentHandler
Dim atrs As New SAXAttributes50
Set cnth = wrt
wrt.indent = True 
cnth.startDocument
cnth.startElement "", "", "html", atrs
cnth.startElement "", "", "body", atrs
cnth.characters "This is a test"
cnth.endElement "", "", "body"
cnth.endElement "", "", "html"
MsgBox wrt.output

Results

<html>
    <body>This is a test
    </body>
</html>
[C/C++]

Syntax

[propput]
HRESULT indent (
   [in] VARIANT_BOOL fIndentMode);
[propget]
HRESULT indent (
   [out, retval] VARIANT_BOOL * fIndentMode);

Parameters

fIndentMode
A Boolean expression (True/False) specifying whether the feature is on or off.

Return Values

S_OK
The value returned if no errors are reported.

Remarks

The default of this property depends on the implementation. The general rules of indentation are: XML headers and root elements start on a new line with a zero indent; element content, including leading and trailing white spaces, is not changed in any way.

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

IMXWriter Interface | MXXMLWriter CoClass

Applies to: MXHTMLWriter CoClass