?
Solved

Change XMLDocument Encoding

Posted on 2006-05-25
2
Medium Priority
?
3,262 Views
Last Modified: 2008-01-09
I've loaded the xml below into an XMLDocument (call it XmlDoc).

Is there a way to programmatically change the encoding attribute value to "utf-8" (or whatever),
OTHER than doing a string replace on the innerText of the XMLDocumentDeclaration?

'===========================================
<?xml version="1.0" encoding="utf-16" ?>
<Control>
      <Value1>
            <SubVal1A>Units</SubVal1A>
            <SubVal1B>Type</SubVal1B>      
      </Value1>
      <Value2>
            <SubVal2A>Over</SubVal2A>
            <SubVal2B>Load</SubVal2B>
      </Value2>
</Control>
0
Comment
Question by:codequest
1 Comment
 
LVL 2

Accepted Solution

by:
codequest earned 0 total points
ID: 16772104
Well, there's this, but it uses the replace function

Public Sub ConvertEncoding(ByRef vXDoc As XmlDocument, ByVal vCode As String)
     Dim wN1 As XmlNode = vXDoc.CreateNode(XmlNodeType.Element, "ss", "xxx")
     wN1 = varXDoc.FirstChild
     wN1.InnerText = Replace(wN1.InnerText, "utf-16", varCode)
     wN1.InnerText = Replace(wkN1.InnerText, "utf-8", varCode)
End Sub

I was hoping there might be some method that could get at the encoding as an element of the DOM.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question