XML文件源码察看器(六)

        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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值