output Property

MSXML 5.0 SDK

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

output Property

Determines the destination and the type of output for MXXMLWriter. By default, the output property is a BSTR (string) value.

Output for IMXWriter can be set as one of the following:

  • Any implementation of the IStream interface. (The resulting document will be written into the provided IStream.)
  • A string.
  • A DOMDocument object.

    For more information about setting the output property to a DOMDocument object, see Create a DOMDocument Object from SAX Events

Setting the output property to the empty value (VT_EMPTY or " ") will return output to the internal string and reset it.

[Visual Basic]

Usage Syntax

oMXXMLWriter.output = varDestination
varDestination = oMXXMLWriter.output

Remarks

Read/write. Variant destination.

Example

The following example creates an instance of MXXMLWriter and sets it to the ContentHandler. Method calls on the ContentHandler are used to manually generate a document. In the sample, a DOMDocument object is created, and the writer output is set to the DOMDocument object. The example code produces three message boxes. The first box shows the DOMDocument object as it is being built (For example, <catalog><book id="bk101"/></catalog>). The second message box shows the finished document. The third message box shows the text in the first <author> tag, Gambardella, Matthew.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim nodeList As IXMLDOMNodeList
Dim wrt As New MXXMLWriter50
Dim cnth As IVBSAXContentHandler
Dim atrs As New SAXAttributes50

Set cnth = wrt

wrt.output = xmlDoc
    
'sets standalone="yes" in the XML declaration
'wrt.standalone = True
'configures the writer to indent elements
wrt.indent = True

'starts the document by addding the XML declaration
cnth.startDocument

'adds the <catalog> element to the page
cnth.startElement "", "", "catalog", atrs

'adds the id attribute to the collection witht he "bk0101" value.
atrs.addAttribute "", "", "id", "CDATA", "bk101"
'creates the <book id="bk101"> tag
cnth.startElement "", "", "book", atrs
'clears the attribute collection
atrs.Clear

MsgBox xmlDoc.xml

'creates the <author>Gambardella, Matthew</author> string
cnth.startElement "", "", "author", atrs
cnth.characters "Gambardella, Matthew"
cnth.endElement "", "", "author"

'creates the <title>XML Developer's Guide</title> string
cnth.startElement "", "", "title", atrs
cnth.characters "XML Developer's Guide"
cnth.endElement "", "", "title"
    
'creates the <description>An in-depth look at...</description> string
cnth.startElement "", "", "description", atrs
cnth.characters "An in-depth look at creating applications with XML"
cnth.endElement "", "", "description"

'adds closing tags for <book> and <catalog> elements
cnth.endElement "", "", "book"
cnth.endElement "", "", "catalog"

'ends the document
cnth.endDocument

'displays the author's name in a message box
MsgBox xmlDoc.xml
Set objNodeList = xmlDoc.getElementsByTagName("author")
MsgBox objNodeList.Item(0).Text
[C/C++]

Syntax

[propput]
HRESULT output (
   [in] VARIANT varDestination);
[propget]
HRESULT output (
   [out, retval] VARIANT * varDestination);

Parameters

varDestination
The variant destination.

Return Values

S_OK
The value returned if no errors are reported.

Remarks

The default is output to string.

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

Create a DOMDocument Object from SAX Events | IMXWriter Interface | MXHTMLWriter CoClass

Applies to: MXXMLWriter CoClass