Advertisement

08.17.2007 at 03:34PM PDT, ID: 22771035
[x]
Attachment Details

MSXML2.DOMDocument   documentElement-Question

Asked by chriswies in .Net Editors & IDEs, Extensible Markup Language (XML), Microsoft Programming

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.IXMLDOMProcessingInstruction
    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.createProcessingInstruction("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.createElement(varvalue(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>mySting2</ODBC></data>

Start Free Trial
 
 
[+][-]08.17.2007 at 10:40PM PDT, ID: 19721820

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Extensible Markup Language (XML), Microsoft Programming
Sign Up Now!
Solution Provided By: drichards
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.18.2007 at 02:08AM PDT, ID: 19722084

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2007 at 10:57AM PDT, ID: 19732239

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2007 at 11:12AM PDT, ID: 19732359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628