Tabular Data Binding and XML

When you bind a recordset to an HTML table, the table can display the entire recordset. Here's an example. In this case, I'll bind the data in ch08_03.xml to a table. I start by creating an XML data island, giving the data island the ID of customers :

 <HTML>      <HEAD>         <TITLE>             Tabular Binding with XML Data Islands         </TITLE>     </HEAD>     <BODY>         <CENTER>             <H1>                 Tabular Binding with XML Data Islands             </H1>  <XML SRC="ch08_03.xml" ID="customers"></XML>  .             .             . 

To bind the data in ch08_03.xml to a table, all I have to do is set a table's DATASRC attribute to customers :

 <XML SRC="ch08_03.xml" ID="customers"></XML>  <TABLE DATASRC="#customers" CELLSPACING="10">  .              .              . 

The fields in the records of ch08_03.xml are NAME , CUSTOMER_ID , PURCHASE_DATE , DEPARTMENT , and PRODUCT . I will bind those fields to the individual cells in a table like this using the DATAFLD attribute:

Listing ch08_06.html
 <HTML>     <HEAD>         <TITLE>             Tabular Binding with XML Data Islands         </TITLE>     </HEAD>     <BODY>         <CENTER>             <H1>                 Tabular Binding with XML Data Islands             </H1>             <XML SRC="ch08_03.xml" ID="customers"></XML>              <TABLE DATASRC="#customers" CELLSPACING="10">                  <THEAD>                      <TR>                          <TH>Name</TH>                          <TH>Customer ID</TH>                          <TH>Purchase Date</TH>                          <TH>Department</TH>                          <TH>Product</TH>                      </TR>                   </THEAD>                   <TBODY>                       <TR>                           <TD>                               <SPAN DATAFLD="NAME">                               </SPAN>                           </TD>                           <TD>                               <SPAN DATAFLD="CUSTOMER_ID">                               </SPAN>                           </TD>                           <TD>                               <SPAN DATAFLD="PURCHASE_DATE">                               </SPAN>                           </TD>                           <TD>                               <SPAN DATAFLD="DEPARTMENT">                               </SPAN>                           </TD>                           <TD>                               <SPAN DATAFLD="PRODUCT_NAME">                               </SPAN>                           </TD>                        </TR>                   </TBODY>             </TABLE>         </CENTER>     </BODY> </HTML> 

You can see the results in Figure 8-4, where the data from ch08_03.xml is displayed in a table.

Figure 8-4. Binding data to a table in Internet Explorer.

graphics/08fig04.gif

There's another DSO you can use with XML documents in Internet Explorer: the XML DSO.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net