简单的xml操作.
//得到节点的Text值
function getNodeText(obj)
{
if(!obj)
{
return "";
}
if(obj.textContent)
{
return obj.textContent;
}
if(obj.firstChild)
{
obj=obj.firstChild;
}
if(obj.nodeValue)
{
return obj.nodeValue;
}
if(obj.data)
{
return obj.data;
}
return "";
}
function getNodeAttribute(node,name)
{
if(!node || !name)
{
return false;
}
return getAttribute(name,node.attributes);
}
//得到某个属性
function getAttribute(name,list)
{
if(!list)
{
return false;
}
for(var i=0;i<list.length;i++)
{
if(list[i].nodeName.toLowerCase()==name.toLowerCase())
{
return list[i];
}
}
return false;
}
转载于:https://www.cnblogs.com/Chailizi/articles/1041679.html