Save xml-file with OpenTextFile and UTF-8 encoding

Dear All,
I am working with InfoPath and got a VBscript that creates an XML-file with the following commands:
Set oFS = CreateObject("Scripting.FileSystemObject")
Set objXMLFile = oFS.OpenTextFile(filename,2,true,TristateFalse)
objXMLFile.Write(XDocument.DOM.xml)
objXMLFile.Close

The problem is that the xml-file includes data with "umlauts" and can not be parsed in InfoPath as it is. If I open the xml-file with notepad and save it again with the encoding utf-8 it is working perfect.

Is there a way to create the file with the script that is saved with the UTF-8 encoding?

Please ask if anything is not clear.

Thanks in advance and greetings
Marcus
Marcus_KuhnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

spinzr0Commented:
Yes, just use this to create the file:

Set oFS = CreateObject("Scripting.FileSystemObject")
Set objXMLFile = oFS.CreateTextFile(filename,True,True)
objXMLFile.Write(XDocument.DOM.xml)
objXMLFile.Close
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marcus_KuhnAuthor Commented:
Thanks for the answer. I am not at work at the moment so I can not test it but are you sure that this works, because I already tried out all three "Tristate"-options and it did not work.

I will test it tomorrow. Thanks
0
spinzr0Commented:
I use this all the time to handle unicode characters for our Asian offices.  It should work for you as well.  If not, I can definitely dig deper.
0
Marcus_KuhnAuthor Commented:
It worked. Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.