Solved

encoding is removed on MSXML2.DOMDocument.loadXML

Posted on 2007-11-21
3
1,939 Views
Last Modified: 2010-07-27
Hi!
I have an XML string that starts with the following "<?xml version=""1.0"" encoding=""iso-8859-1""?>...

however when loading the string with MSXML2.DOMDocument.loadXML the encoding attribute is removed and all that is left on the first row is "<?xml version="1.0"?>...

I need to set the encoding in order to succeed to send my request to a webservice but I have tried everything without succeeding...

What I have tried for exemple is to: (xmlCustomersRequest beeing my MSXML2.DOMDocument object)
-Call xmlCustomersRequest.childNodes(xmlCustomersRequest.createProcessingInstruction("xml", "version='1.0' encoding='iso-8859-1'")) - this worked BUT it removed the encoding again and only added another <?xml version="1.0"?> at the end of the xml...

-to add the first row upon sending the request: (I remove it first from the xmlstring of course)
objHTTP.Send ("<xml version=""1.0"" encoding=""ISO-8859-1"">" + xmlCustomersRequest.XML) - this wasn't allowed

to replace the "<?xml version=""1.0""?>" upon sending the request:
objHTTP.Send(VBA.Replace(xmlCustomersRequest.XML, "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""ISO-8859-1""?>") - but this wasn't allowed either

If someone have the solution to this problem please please please enlight me!!
0
Comment
Question by:Lime_Sweden
3 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 20336182
If I understand correctly, the encoding is not part of the XML document - it is guidance to converting the sequence of bytes in the input into a string.  Once you HAVE it as a string, it is no longer encoded, so it makes sense for the encoding to "disappear", since when you output the document you could use a completely different encoding.

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

770 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