Why can't I read the document content??
All is working fine when working with ascii-charset.
But I need to store a RC4 string in the xml-File. Then
Dim xmlRoot As MSXML2.IXMLDOMNode
Dim xmlDoc As New MSXML2.
xmlDoc.Load
Set xmlRoot = xmlDoc.documentElement() --> stays NOTHING
I tried to create the file on different ways but nothing helped. I'm convinced that I am totally on the wrong track.
Does anybody has an idea? How do I have to handle encoding here?
Chris
These are the 3 ways I checked out concerning file creation
#1
Open strFullFileName For Output As #lngFileNum
Print #lngFileNum, strText
Close #lngFileNum
#2
Dim stm As ADODB.Stream
Dim strpath As String
strpath = strFullFileName
Set stm = New ADODB.Stream
stm.Open
stm.Charset = "UTF-8"
stm.WriteText strText, adWriteChar
stm.SaveToFile strpath, adSaveCreateOverWrite
#3
Dim docOut As MSXML2.DOMDocument
Dim domPI As MSXML2.IXMLDOMProcessingIn
struction
Dim eleRoot As MSXML2.IXMLDOMElement
Dim eleChild As MSXML2.IXMLDOMElement
Dim strpath As String
Dim i As Long
Dim varvalue As Variant
Set docOut = New MSXML2.DOMDocument
Set domPI = docOut.createProcessingIns
truction("
xml", "version='1.0' encoding='UTF-8'")
docOut.appendChild domPI
Set eleRoot = docOut.createElement("data
")
docOut.appendChild eleRoot
For i = 0 To UBound(varData)
varvalue = varData(i)
Set eleChild = eleRoot.appendChild(docOut
.createEle
ment(varva
lue(0)))
eleChild.Text = varvalue(1)
Next i
strpath = "Y:\MyDocuments\hfp\02 Prüfungsmanager\Version 4.0\asdf.xml"
On Error Resume Next
Kill strpath
docOut.Save strpath
Give it a try:
This one failes
<?xml version="1.0" encoding="UTF-8"?>
<data><ADO>ó!¬â¡Cê¸TþHâ
©dû¼R¿709-
ç </ADO><ODBC>ó!¬â¡Cê¸TþHâ
©dû¼R¿709
-ç </ODBC></data>
This one succeeds
<?xml version="1.0" encoding="UTF-8"?>
<data><ADO>myString</ADO><
ODBC>mySti
ng2</ODBC>
</data>
Start Free Trial