perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Tuesday, 14 August 2007
 
NEWS
MSXML 4.0 SP2 now available!

 
MSXML
Basics
DOM
SAX
XPath
XSLT
Schemas
SOM
HTTP Access
.NET
Data Islands
Ask a Question
   Past Q&As
C++ Samples
DLL/Version Info
Reference Guide
Books
KB Articles
   HOW TO
   SAMPLE
   INFO
   BUG/PRB
   FIX
   Misc.
MSXML Tips
   August 2002
   September 2002
MSXML Tools

Microsoft XML Core Services


Go back to list of previously asked questions and answers

Question: Is it possible to create XML documents using MSXML 4.0 SAX 2.0 implementation.
Asked By: Thomas Jacob
Viewed: 2711
Answer: Yes.

You may use MXXMLWriter (an IMXWriter interface implementation class) to build the XML documents using SAX. Here is an example:
Start Visual Basic 6.0, create a standard EXE project, add reference (Project | References) to MSXML 4.0, and write the following code in the Form_Load method:

Dim writer As New MXXMLWriter40
Dim CH As IVBSAXContentHandler
Dim attrib As IVBSAXAttributes
    
writer.encoding = "UTF-8"
writer.indent = True
Set CH = writer
    
CH.startDocument
    
CH.startElement "", "", "WebSites", attrib
   
CH.characters "perfectxml.com"
    
CH.endElement "", "", "WebSites"
    
CH.endDocument
    
MsgBox writer.output

The book XML Application Development with MSXML 4.0 containing many more examples of using SAX to create documents using MXXMLWriter.


Go back to list of previously asked questions and answers
  Contact Us |  | Site Guide | About PerfectXML | Advertise ©2004 perfectxml.com. All rights reserved. | Privacy