无聊写了个遍历XML文件的文档,还有一些不够完美,大家如果有更好的可以贴出来一起研究一下!
<% on error resume next
'<![CDATA[]]>问题没处理
xmlfile = Server.MapPath("???.xml")
Set xml = Server.CreateObject("MSXML.DOMDocument")
xml.async = false
xml.load(xmlfile)
private function showxml(node)
dim tempstr
for each i in node
If i.nodeType = 1 then
tempstr = "<b>" & i.nodeName & "</b>"
tempstr = replace(tempstr,"#text","")
Response.write tempstr
end if
If i.nodeType = 3 then
tempstr = "<i>" & i.nodeValue & "</i><br>"
response.write tempstr
end if
If i.nodeName<>"#text" then
for each b in i.attributes
response.write "[" & b.name & ":" & b.value & "] "
Next
Response.write "<br>"
end if
If i.hasChildNodes then
showxml(i.childNodes)
end if
Next
End function
showxml(xml.documentElement.childNodes)
%>
博主分享了一段遍历XML文件的代码,代码中创建了XML对象并加载文件,定义了遍历函数,对不同节点类型进行处理,还处理了节点属性,不过代码中存在问题未处理,希望大家分享更好的代码一起研究。
&spm=1001.2101.3001.5002&articleId=373533&d=1&t=3&u=d984974e7ede48f28c27fcd046ed4881)
3772

被折叠的 条评论
为什么被折叠?



