1个回答
展开全部
我自己用的代码,支持FF和IE:
能看懂最好,看不懂也不要来问我了。
var XML=new Object;
XML.newDocument = function(rootTagName) {
if (!rootTagName) rootTagName = "";
if (document.implementation && document.implementation.createDocument) {
return document.implementation.createDocument("", rootTagName, null);
}
else {
var doc = new ActiveXObject("MSXML2.DOMDocument");
if (rootTagName) {
var text = "<" + rootTagName + "/>";
doc.loadXML(text);
}
return doc;
}
};
XML.serialize = function(node) {
if (typeof XMLSerializer != "undefined")
return (new XMLSerializer( )).serializeToString(node);
else if (node.xml) return node.xml;
else throw "XML.serialize is not supported or can't serialize " + node;
};
function Preview()
{
var xmlDoc = new XML.newDocument("Data");
var xmlRoot = xmlDoc.documentElement;
xmlRoot.setAttribute("URL","http://");
xmlString = XML.serialize(xmlDoc);
}
能看懂最好,看不懂也不要来问我了。
var XML=new Object;
XML.newDocument = function(rootTagName) {
if (!rootTagName) rootTagName = "";
if (document.implementation && document.implementation.createDocument) {
return document.implementation.createDocument("", rootTagName, null);
}
else {
var doc = new ActiveXObject("MSXML2.DOMDocument");
if (rootTagName) {
var text = "<" + rootTagName + "/>";
doc.loadXML(text);
}
return doc;
}
};
XML.serialize = function(node) {
if (typeof XMLSerializer != "undefined")
return (new XMLSerializer( )).serializeToString(node);
else if (node.xml) return node.xml;
else throw "XML.serialize is not supported or can't serialize " + node;
};
function Preview()
{
var xmlDoc = new XML.newDocument("Data");
var xmlRoot = xmlDoc.documentElement;
xmlRoot.setAttribute("URL","http://");
xmlString = XML.serialize(xmlDoc);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询