utl.js
代码如下:function createXmlTree(node, indent) {
if (node == null)
return "";
var str = "";
switch (node.nodeType) {
case 1: // Element
str += "<div class='element'><<span class='elementname'>" + node.nodeName + "</span>";
var attrs = node.attributes;
for (var i = 0; i < attrs.length; i++)
str += createXmlAttribute(attrs[i]);
if (!node.hasChildNodes())
return str + "/></div>";
str += "><br />";
var cs = node.childNodes;
for (var i = 0; i < cs.length; i++)
str += createXmlTree(cs[i], indent + 3);
str += "</<span class='elementname'>" + node.nodeName + "</span>></div>";
break;
case 9: // Document
var cs = node.childNodes;
for (var i = 0; i < cs.length; i++)
str += createXmlTree(cs[i], indent);
break;
case 3: // Text
if (!/^/s*$/.test(node.nodeValue))
str += "<span class='text'>" + node.nodeValue + "</span><br />";
新闻热点
疑难解答
图片精选