perfectxml.com
 Basic Search  Advanced Search   
Topics Resources Free Library Software XML News About Us
home » focus » msxml » ask a question » past questions & answers Thursday, 11 October 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: I would like to create a XML document containing Unicode (UTF-16) data, in Visual Basic 6.0. Can you please provide an example of how to do this?
Asked By: Sharad
Viewed: 1463
Answer: Try the following Visual Basic Example (add reference to MSXML 4.0):
Dim ObjXMLDom As New MSXML2.DOMDocument40
Dim xmlDeclPI As MSXML2.IXMLDOMProcessingInstruction
    
Set xmlDeclPI = _
    ObjXMLDom.createProcessingInstruction _
        ("xml", "version='1.0' encoding='UTF-16'")
    
With ObjXMLDom
    .insertBefore xmlDeclPI, .childNodes.Item(0)
        
    Set .documentElement = .createElement("Customer")
        
    .documentElement.nodeTypedValue = ""
        
    .save "c:\1.xml"
        
End With
We tried the above code with MSXML 4.0 SP1, and after running it, we browsed to the created file (c:\1.xml) in Internet Explorer and could see the special characters and encoding attribute correctly.


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