FireFox下XML对象转化成字符串的解决方法
人气:0
解决方法如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>xml转化成字符串</title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
//使fireFox也支持xmlDom.xml
if (!document.all) {
Node.prototype.__defineGetter__(
"xml",
function () {
return (new XMLSerializer).serializeToString(this);
});
}
alert(1);
var xmlStr = "<test>Hello world</test>";
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlStr, "text/xml");
alert(xmlDoc.documentElement.nodeName);
alert(xmlDoc.xml);
});
</script>
</head>
<body>
</body>
</html>
复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>xml转化成字符串</title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
//使fireFox也支持xmlDom.xml
if (!document.all) {
Node.prototype.__defineGetter__(
"xml",
function () {
return (new XMLSerializer).serializeToString(this);
});
}
alert(1);
var xmlStr = "<test>Hello world</test>";
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlStr, "text/xml");
alert(xmlDoc.documentElement.nodeName);
alert(xmlDoc.xml);
});
</script>
</head>
<body>
</body>
</html>
加载全部内容