output Property
Sets the destination and the type of output for IMXWriter
. By default, the output
property is a BSTR (string) value. Output can be:
- any implementation of the
IStream
interface. (The resulting document will be written into the providedIStream
). - String.
DOMDocument
object.For more information about setting the
output
property to aDOMDocument
object, see Create a DOMDocument Object from SAX Events.
Setting this property to the empty value (VT_EMPTY or " ") will return output to the internal string and reset it.
Implementation Syntax
Private Property Let IMXWriter_output(ByVal RHS As Variant) Private Property Get IMXWriter_output() As Variant
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. After the contents of the output
property are loaded into a DOMDocument
object, they are then displayed in message box.
XML File
Use books.xml.
Visual Basic File (Form1.frm)
Private Sub Command1_Click() Dim wrt As New MXXMLWriter50 Dim cnth As IVBSAXContentHandler Dim atrs As New SAXAttributes50 Dim xmlDoc As New DOMDocument50 Dim currNode As IXMLDOMNode Set cnth = wrt wrt.output = xmlDoc cnth.startDocument cnth.startElement "", "", "catalog", atrs atrs.addAttribute "", "", "id", "CDATA", "bk101" cnth.startElement "", "", "book", atrs atrs.Clear cnth.startElement "", "", "author", atrs cnth.characters "Gambardella, Matthew" cnth.endElement "", "", "author" cnth.startElement "", "", "title", atrs cnth.characters "XML Developer's Guide" cnth.endElement "", "", "title" cnth.startElement "", "", "description", atrs cnth.characters "An in-depth look at creating applications with XML" cnth.endElement "", "", "description" cnth.endElement "", "", "book" cnth.endElement "", "", "catalog" 'Ends the document. cnth.endDocument Set currNode = xmlDoc.documentElement MsgBox currNode.xml End Sub
Try It!
- Open Visual Basic and create a new Standard EXE project.
- Create a reference in the project to Microsoft XML, v5.0.
- Add a command button (Command1) to the application form (Form1).
- From the View menu, click Code.
- Use copy and paste to replace any code in the form with the code provided above.
- From the Run menu, click Start.
- In the test application, click Command1 (the command button).
Output
When run, the sample Visual Basic application should display in a message box the contents of the XML document element (the <catalog>
element and all its node children) that was created using SAX ContentHandler
method calls.
The output text should be this:
<catalog><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><description>An in-depth look at creating applications with XML</description></book></catalog>
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 VT_EMPTY to output to string.
To view reference information for Visual Basic or C/C++ only, click the Language Filter button in the upper-left corner of the page.
See Also
MXHTMLWriter CoClass | MXXMLWriter CoClass
Applies to: IMXWriter Interface