Can't create XML node with cyrillic name in IE11 Can't create XML node with cyrillic name in IE11 xml xml

Can't create XML node with cyrillic name in IE11


Maybe IE11 has an issue similar to what Firefox had in the past:

https://bugzilla.mozilla.org/show_bug.cgi?id=431701

That means that although your page is loading the correct encoding, IE11 is creating the new document with a default encoding which is not the expected one. There's no way to check that besides looking into IE11 source code, which we don't have.

Have you trying to add non-ASCII characters in other places besides element names? Like an attribute value or a text node?

I searched how to change the created document encoding and haven't found any solution for that.

To solve your problem I would suggest to use a DOMParser and generate a document from a XML string, like the following:

var parser=new DOMParser();var xmlDoc=parser.parseFromString('<?xml version="1.0" encoding="UTF-8"?><Выборка>Выборка текста</Выборка>',"text/xml");

All browsers seems to support it for XML parsing. More about DOMParser on the following links, including how to provide backward compatibility with older IE versions:

http://www.w3schools.com/dom/dom_parser.asp

https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

If you don't want to generate your XML just by concatenating strings, you can use some kind of XML builder like in this example: http://jsfiddle.net/UGYWx/6/

Then you can easily create your XML in a more safe manner:

var builder = new XMLBuilder("rootElement");builder.text('Some text');var element = builder.element("someElement", {'attr':'value'});element.text("This is a text.");builder.text('Some more Text');builder.element("emptyElement");builder.text('Even some more text');builder.element("emptyWithAttributes", {'a1': 'val1', 'a2' : 'val2'});$('div').text(builder.toString());


I have always been very reluctant to use non-ASCII characters inside source code. Try escaping the string; maybe it helps.

doc.createElement("\u0412\u044B\u0431\u043E\u0440\u043A\u0430")