XML文件源码察看器(六)

王朝vc·作者佚名  2006-01-08
宽屏版  字体: |||超大  

case 9: 'Document 节点 -- “根”节点。不需要显示,只需显示子节点

'遍历节点的子节点就是这样写地 : ) ,so easy

intCount = nodNode.childNodes.length

if intCount > 0 then

for intNode = 0 to intCount-1

strNodes =strNodes & renderChildNodes(nodNode.childNodes(intNode), intLevel + 1)

next

end if

case else:'普通节点

strNodes=strNodes & getIndent(intLevel)& "<font color=""blue"">&lt</font>" ' 蓝色 <

strNodes=strNodes & "<font color=""#800000"">"& nodNode.nodeName & "</font> " ' 褐色 node name

'显示 属性

set nodAttrList = nodNode.attributes'得到属性节点集(collection -- 我最喜欢的数据类型之一)先

intCount = nodAttrList.length 'collection 之 length ,方便吧? :)

if intCount > 0 then

for intAttr = 0 to intCount-1

'红色 属性名,蓝色 引号

strNodes =strNodes & "<font color=""red"">"+nodAttrList(intAttr).nodeName + "</font>=<font color=""blue"">""</font>" & nodAttrList(intAttr).nodeValue & "<font color=""blue"">""</font> "

next

end if

'处理当前节点的子节点

intCount = nodNode.childNodes.length

if intCount > 0 then'如果有子节点

strNodes=strNodes & "<font color=""blue"">&gt</font><br>" '属性显示完 ,用“ 〉“闭合 Tag先

' 对每个子节点递归调用 renderChildNodes

for intNode = 0 to intCount-1

strNodes = strNodes & renderChildNodes(nodNode.childNodes(intNode), intLevel + 1)

next

'显示关闭标记 </NodeName>

strNodes= strNodes & getIndent(intLevel) & "<font color=""blue"">&lt/</font><font color=""#800000"">"+nodNode.nodeName & "</font><font color=""blue"">&gt</font><br>"

else

strNodes = strNodes & "<font color=""blue"">/&gt</font><br>" '没有子节点, 显示 “ /〉“

end if

end select

renderChildNodes = strNodes

end function

'给注释节点着色

function renderComment(nodNode,intLevel)

dim strNodes,intCount,intNode

strNodes = ""

intCount = 0

intNode = 0

dim nodAttrList

strNodes=strNodes & getIndent(intLevel)& "<font color=""gray"">&lt!-- "

strNodes= strNodes & nodNode.nodeValue

strNodes=strNodes &" --&gt</font><br>"

renderComment = strNodes

end function

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有