The following code shows how to set the DOMDocument
object as MXXMLWriter
output and how to get the DOMDocument
output using DOMDocument
methods.
The following code shows how to set writer output as a DOMDocument
object.
Private Sub Command1_Click() 'Create the DOMDocument object. Dim xmlDoc As New Msxml2.DOMDocument50 'Create an MXXMLWriter object. Dim wrt As New MXXMLWriter50 'Reference the ContentHandler interface. Dim cnth As IVBSAXContentHandler 'Set the writer as the content handler. Set cnth = wrt 'Set the writer output to the xmlDoc object. wrt.output = xmlDoc
You can read the document at any time after the startDocument
event is called. However, you cannot modify the document until after the endDocument
event is called. The following code shows DOMDocument
methods called on the xmlDoc
object after the endElement
method is called.
cnth.endDocument 'Displays the author's name in a message box. Set objNodeList = xmlDoc.getElementsByTagName("author") MsgBox objNodeList.Item(0).Text
SAX to DOM Implementation Notes | MXXMLWriter CoClass | output Property | DOMDocument