zoukankan      html  css  js  c++  java
  • HTML与XML数据的结合小总结

    *******************************
    建立一个data.xml先

      <?xml version="1.0" encoding="gb2312"?>
      
    <myclassmates>
        
    <classmate>
          
    <name>11</name>
          
    <age>11</name>
        
    </classmate>
      
    </myclassmates>

    *************************
    * 在HTML中显示xml中的数据
    *************************
    NO.1--用很简单的数据绑定了

    NO.2--表格绑定数据(很好的)
          <xml id=xmldata src=data.xml></xml>
          <table id=xmltable datasrc="#xmldata" datapagesize="3">
          <theme>
          <th>Name</th><th>Age</th>
          <tr>
          <td><span datafld="name"></span></td>
          <td><span datafld="age"></span></td>
          </table>
    NO.3--用css来显示(没有html的事情)
           建立css
           name{display:block;font-size:22pt;color:#ccccff;background-color:red}
           age{display:block;font-size:12pt}
           在data.xml连接css
           <?xml-stylesheet href="css.css" type="text/css"?>
    NO.4--用xsl来显示(不说了)
    NO.5--用ASP的xmlDOM对象也可以,不过不是今天讨论的范围

    ***********************
    *  操作xml数据
    ***********************
    用vbs或者js来搞定

    例如上面的NO.1
         <button onclick="xmldata.recoreset.movefirst()">First</button>
         <button onclick="if(xmldata.recordset.absoluteposition<>1) xmldata.recordset.moveprevious()">Prev</button>
         <button onclick="if(xmldata.recordset.absoluteposition<>xmldata.recordset.recodcount)xmldata.recordset.movenext()">Next</button>
         <button onclick="xmldata.recordset.movelast()">Last</button>
    上面的NO.2可以分页显示了:
         <button onclick="xmltable.firstPage()">First</button>
         <button onclick="xmltable.previousPage()">Prev</button>
         <button onclick="xmltable.nextPage()">Next</button>
         <button onclick="xmltable.lastPage()">Last</button>
     
    ******************
    *  对xml文件的查询
    ******************
    连接xml文档:<xml id=xmldata src=data.xml></xml>
                   <input type=button value=search name=btnsearch>
       构建vbs查询函数

       <script language=vbscript>
    sub btnsearch_onclick()
    document.all.spnadd.innerhtml
    =""
    str=inputbox("Input the name you want to search")

    xmldata.recordset.movefirst()

    for i=1 to xmldata.recordset.recordcount 
       myname
    =xmldata.recordset("name").value
       
       
    if myname=str then
        
          document.all.spnadd.innerhtml
    =document.all.spnadd.innerhtml & "<tr><td><b>Name:</b>"& xmldata.recordset("name").value & "</td><td><b>QQ:</b>" & xmldata.recordset("qq").value & "</td><td><b>Mail:</b>" & xmldata.recordset("email").value & "</td><td><b>Message:</b>" & xmldata.recordset("message").value &"</td></tr><br>"
     
       
    end if
    xmldata.recordset.movenext()
    next
    end sub
      
    </script>

      
    ********************
    对于xml文件的增加,删除,修改,静态HTML就无能为力了
    可以用asp的fso,或者(必须)Microsoft.xmlDOM对象了

  • 相关阅读:
    Redis21:客户端与服务器端的通信与redis管道
    Redis20:keys、scan、bigkeys、查看key的存储方式
    Redis19:限流
    Redis18:分布式锁
    Redis17:cluster集群
    Redis16:两种redis集群解决方案:codis和cluster
    Android : 获取声卡信息的测试代码
    Android : 基于alsa库的音乐播放
    Android system :灯光系统_HAL_lights
    Android system :led_class驱动
  • 原文地址:https://www.cnblogs.com/caca/p/25018.html
Copyright © 2011-2022 走看看