xml介绍系列(7)

  • 作者:未知 来源:未知 添加时间:2006年7月3日 字体:

  • 系列之十四:xml的典型运用(一)
    我觉得,大家多看些xml的具体例子要比看那些枯燥的
    理论有兴趣得多,所以先给大家介绍一些例子。
    第一个例子是如何把xml的数据绑定到html的元素中。
    浏览数据
    xml的数据文件cd_catalog.xml
    <catalog>
    <cd>
    <title>empire burlesque</title>
    <artist>bob dylan</artist>
    <country>usa</country>
    <company>columbia</company>
    <price>10.90</price>
    <year>1985</year>
    </cd>
    <cd>
    <title>hide your heart</title>
    <artist>bonnie tylor</artist>
    <country>uk</country>
    <company>cbs records</company>
    <price>9.90</price>
    <year>1988</year>
    </cd>
    <cd>
    <title>greatest hits</title>
    <artist>dolly parton</artist>
    <country>usa</country>
    <company>rca</company>
    <price>9.90</price>
    <year>1982</year>
    </cd>
    <cd>
    <title>still got the blues</title>
    <artist>gary more</artist>
    <country>uk</country>
    <company>virgin redords</company>
    <price>10.20</price>
    <year>1990</year>
    </cd>
    <cd>
    <title>eros</title>
    <artist>eros ramazzotti</artist>
    <country>eu</country>
    <company>bmg</company>
    <price>9.90</price>
    <year>1997</year>
    </cd>
    <cd>
    <title>one night only</title>
    <artist>bee gees</artist>
    <country>uk</country>
    <company>polydor</company>
    <price>10.90</price>
    <year>1998</year>
    </cd>
    <cd>
    <title>one night only</title>
    <artist>bee gees</artist>
    <country>uk</country>
    <company>polydor</company>
    <price>10.90</price>
    <year>1998</year>
    </cd>
    <cd>
    <title>sylvias mother</title>
    <artist>dr.hook</artist>
    <country>uk</country>
    <company>cbs</company>
    <price>8.10</price>
    <year>1973</year>
    </cd>
    <cd>
    <title>maggie may</title>
    <artist>rod stewart</artist>
    <country>uk</country>
    <company>pickwick</company>
    <price>8.50</price>
    <year>1990</year>
    </cd>
    <cd>
    <title>romanza</title>
    <artist>andrea bocelli</artist>
    <country>eu</country>
    <company>polydor</company>
    <price>10.80</price>
    <year>1996</year>
    </cd>
    <cd>
    <title>when a man loves a woman</title>
    <artist>percy sledge</artist>
    <country>usa</country>
    <company>atlantic</company>
    <price>8.70</price>
    <year>1987</year>
    </cd>
    <cd>
    <title>black angel</title>
    <artist>savage rose</artist>
    <country>eu</country>
    <company>mega</company>
    <price>10.90</price>
    <year>1995</year>
    </cd>
    <cd>
    <title>1999 grammy nominees</title>
    <artist>many</artist>
    <country>usa</country>
    <company>grammy</company>
    <price>10.20</price>
    <year>1999</year>
    </cd>
    <cd>
    <title>for the good times</title>
    <artist>kenny rogers</artist>
    <country>uk</country>
    <company>mucik master</company>
    <price>8.70</price>
    <year>1995</year>
    </cd>
    <cd>
    <title>big willie style</title>
    <artist>will smith</artist>
    <country>usa</country>
    <company>columbia</company>
    <price>9.90</price>
    <year>1997</year>
    </cd>
    <cd>
    <title>tupelo honey</title>
    <artist>van morrison</artist>
    <country>uk</country>
    <company>polydor</company>
    <price>8.20</price>
    <year>1971</year>
    </cd>
    <cd>
    <title>soulsville</title>
    <artist>jorn hoel</artist>
    <country>norway</country>
    <company>wea</company>
    <price>7.90</price>
    <year>1996</year>
    </cd>
    <cd>
    <title>the very best of</title>
    <artist>cat stevens</artist>
    <country>uk</country>
    <company>island</company>
    <price>8.90</price>
    <year>1990</year>
    </cd>
    <cd>
    <title>stop</title>
    <artist>sam brown</artist>
    <country>uk</country>
    <company>a and m</company>
    <price>8.90</price>
    <year>1988</year>
    </cd>
    <cd>
    <title>bridge of spies</title>
    <artist>t`pau</artist>
    <country>uk</country>
    <company>siren</company>
    <price>7.90</price>
    <year>1987</year>
    </cd>
    <cd>
    <title>private dancer</title>
    <artist>tina turner</artist>
    <country>uk</country>
    <company>capitol</company>
    <price>8.90</price>
    <year>1983</year>
    </cd>
    <cd>
    <title>midt om natten</title>
    <artist>kim larsen</artist>
    <country>eu</country>
    <company>medley</company>
    <price>7.80</price>
    <year>1983</year>
    </cd>
    <cd>
    <title>pavarotti gala concert</title>
    <artist>luciano pavarotti</artist>
    <country>uk</country>
    <company>decca</company>
    <price>9.90</price>
    <year>1991</year>
    </cd>
    <cd>
    <title>the dock of the bay</title>
    <artist>otis redding</artist>
    <country>usa</country>
    <company>atlantic</company>
    <price>7.90</price>
    <year>1987</year>
    </cd>
    <cd>
    <title>picture book</title>
    <artist>simply red</artist>
    <country>eu</country>
    <company>elektra</company>
    <price>7.20</price>
    <year>1985</year>
    </cd>
    <cd>
    <title>red</title>
    <artist>the communards</artist>
    <country>uk</country>
    <company>london</company>
    <price>7.80</price>
    <year>1987</year>
    </cd>
    <cd>
    <title>unchain my heart</title>
    <artist>joe cocker</artist>
    <country>usa</country>
    <company>emi</company>
    <price>8.20</price>
    <year>1987</year>
    </cd>
    </catalog>

    一个如何把xml显示在表格中的html文件
    cd_list.htm
    <!doctype html public "-/w3c/dtd html 3.2 final/en">
    <html>

    <head>

    <script for="window" event="onload">
    xmldso_list.xmldocument.load("cd_catalog.xml")
    </script>

    <title>cd list</title>
    </head>

    <body>
    <object width="0" height="0"
    classid="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" id="xmldso_list">
    </object>

    <table datasrc=http://www.1fanwen.com/#xmldso_list border="1" cellspacing="5" cellpadding="2">
    <thead>
    <th>title</th><th>artist</th><th>country</th><th>company</th><th>price</th><th>year</th>
    </thead>

    <tr align="center">
    <td><div datafld="title"></td>
    <td><div datafld="artist"></td>
    <td><div datafld="country"></td>
    <td><div datafld="company"></td>
    <td><div datafld="price"></td>
    <td><div datafld="year"></td>
    </tr>

    </table>
    </body>
    </html>

  • 上一篇:xml介绍系列(8)
  • 下一篇:xml介绍系列(6)
  • 最后更新时间:2024年12月22日
  • 返回页面顶端
ppdesk