Comprehensive application example of XML data island

Source: Internet
Author: User

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<XML id = "xmldso" src = "book. xml"> </XML>
<HTML>
<Head>
<Title> display the book information by page. </title>
</Head>
<Script language = "JavaScript">
VaR pageno = 1;
VaR objbook = xmldso. recordset;
Function selectrecord (element)
{
// Obtain the record column number
Recordno = element. parentelement. rowindex;
// Create an XML recordset
Objbook = xmldso. recordset;
// Specify the current location
Objbook. absoluteposition = recordno + (pageno-1) * tblbooks. datapagesize;
// Obtain the element value
Title. innerhtml = objbook ("title"). value;
Bookcategory. innerhtml = objbook ("bookcategory"). value;
ISBN. innerhtml = objbook ("ISBN"). value;
Author. innerhtml = objbook ("author"). value;
Publisher. innerhtml = objbook ("publisher"). value;
Price. innerhtml = objbook ("price"). value;
Remain. innerhtml = objbook ("remain"). value;
}
Function pre_page ()
{
If (pageno> 1)
{
Tblbooks. previouspage ();
Pageno = pageno-1;
}
}
Function next_page ()
{
If (pageno <objbook. recordcount/tblbooks. datapagesize)
{
Tblbooks. nextpage ();
Pageno = pageno + 1;
}
}
</SCRIPT>
<Body>
<Center> <B> display the book information by page </B> </center>
<Table id = "tblbooks" datasrc = "# xmldso" border = "1" align = "center" datapagesize = "3">
<Thead>
<TH> title </Th>
<TH> Category </Th>
<TH> book number </Th>
<TH> author </Th>
<TH> press </Th>
<TH> pricing </Th>
<TH> remaining amount </Th>
</Thead>
<Tr>
<TD onclick = selectrecord (this)> <span dataworks = "title"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworks = "bookcategory"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworks = "ISBN"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworkflow = "author"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworks = "publisher"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworks = "price"> </span> </TD>
<TD onclick = selectrecord (this)> <span dataworks = "remain"> </span> </TD>
</Tr>
</Table>
<Center>
<Input type = "button" onclick = "pre_page ()" value = "Previous Page">
<Input type = "button" onclick = "next_page ()" value = "next page">
<Input type = "text" value = "3" size = "5" onblur = "tblbooks. datapagesize = This. value;"> pen
</Center>
<Center> click the row of books you are interested in </center>
<HR/>
<Center> single book information: Title: <span id = "title"> </span> </center>
<Table border = "1" align = "center">
<Tr>
& Lt; TD width = "50%" & gt;
Category: <span id = "bookcategory"> </span> <br>
Book No.: <span id = "ISBN"> </span> <br>
Author: <span id = "author"> </span> <br>
</TD>
& Lt; TD width = "50%" & gt;
Published: <span id = "publisher"> </span> <br>
Pricing: <span id = "price"> </span> <br>
Remaining: <span id = "remain"> </span> <br>
</TD>
</Tr>

 

</Table>
</Body>
</Html>

 

The execution result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.