XML文件源码察看器(六)

发表于:2007-07-01来源:作者:点击数: 标签:
case 9: Document 节点 -- “根”节点。不需要显示,只需显示子节点 遍历节点的子节点就是这样写地 : ) ,so easy intCount = nodNode.childNodes.length if intCount 0 then for intNode = 0 to intCount-1 strNodes =strNodes renderChildNodes(nodNode.chi

        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




原文转自:http://www.ltesting.net