zoukankan      html  css  js  c++  java
  • XML读取事例程序

    data.xml 数据文件

    1 <?xml version="1.0" encoding="utf-8" ?>
    2  <root>
    3  <row ID="1" COMPNAME="DALIAN" POST="063000" TEL="0315-2695" LEVEL="888888888"/>
    4  <row ID="2" COMPNAME="TIANJUN" POST="063000" TEL="0315-2695" LEVEL="888888888"/>
    5  <row ID="3" COMPNAME="BEIJIN" POST="063000" TEL="0315-2695" LEVEL="888888888"/>
    6  </root>

    读取程序一:遍历全部节点

    <%
    Dim xml,objNode,objAtr,nCntChd,nCntAtr
    Set xml=Server.CreateObject("Microsoft.XMLDOM")

    xml.Async
    =False
    xml.Load(Server.MapPath(
    "data.xml"))
    Set objNode=xml.documentElement

    nCntChd
    =objNode.ChildNodes.length-1
    For i=0 to nCntChd

    Set objAtr=objNode.ChildNodes.item(i)
    nCntAtr
    =objAtr.Attributes.length-1

    For j=0 To nCntAtr
    response.write objAtr.Attributes.item(j).Text
    &"<br>"
    Next

    Response.Write
    "<br>"
    Next

    Response.Write
    "<br>"

    Set objAtr=Nothing
    Set objNode=Nothing
    Set xml=Nothing
    %
    >

     读取程序二:获取“COMPNAME”节点的内容

    <%
    Dim xml,objNode,objAtr,nCntChd,nCntAtr
    Set xml=Server.CreateObject("Microsoft.XMLDOM")

    xml.Async
    =False
    xml.Load(Server.MapPath(
    "data.xml"))
    Set objNode=xml.documentElement

    nCntChd
    =objNode.ChildNodes.length-1
    For i=0 to nCntChd

    Set objAtr=objNode.ChildNodes.item(i)
    nCntAtr
    =objAtr.Attributes.length-1

      response.write objAtr.Attributes.item(i).Text&"<br>"
    Next

    Response.Write
    "<br>"

    Set objAtr=Nothing
    Set objNode=Nothing
    Set xml=Nothing

    %
    >
    我来自:向东博客
  • 相关阅读:
    Pycharm激活
    初识HTML
    软件测试之性能测试应用领域
    剑指offer学习
    编译PC版本的C程序
    嵌入式Linux中Socket套接口开发
    win7安装ubuntu,如何设置win7为默认启动项
    struct v4l2_buffer
    dpkg命令查看 sudo apt-get install ~~ 安装的软件路径
    Missing table when do SQL data compare
  • 原文地址:https://www.cnblogs.com/meil/p/ReadXml.html
Copyright © 2011-2022 走看看