0

This is my code:

var doc = document.implementation.createDocument("", "", null); 
var msg = document.createElement('message');
doc.appendChild(msg);
xml_serial = (new XMLSerializer).serializeToString(doc);

And I get this output:

    <message xmlns="http://www.w3.org/1999/xhtml"> </message>

And my wish is to prevent the namespace, so I want something like this:

    <message> </message>

How can I prevent or delete the namespace?

4

1 回答 1

1

您必须调用.createElement新生成的 - 方法doc,而不是嵌入代码的文档。

var doc = document.implementation.createDocument("", "", null); 
var msg = doc.createElement('message');
于 2013-10-23T23:11:25.350 回答