A summary of the combination of HTML and XML data

Source: Internet
Author: User

*******************************
Create a data. xml first

<? XML version = "1.0" encoding = "gb2312" ?>
< Myclassmates >
< Classmate >
< Name > 11 </ Name >
< Age > 11 </ Name >
</ Classmate >
</ Myclassmates >

*************************
* Display XML data in HTML
*************************
No.1 -- bound with simple data

No. 2 -- table Binding data (good)
<XML id = xmldata src = data. xml> </XML>
<Table id = xmltable datasrc = "# xmldata" datapagesize = "3">
<Theme>
<TH> name </Th> <TH> age </Th>
<Tr>
<TD> <span dataworks = "name"> </span> </TD>
<TD> <span dataworks = "Age"> </span> </TD>
</Table>
No. 3 -- display with CSS (without HTML)
Create CSS
Name {display: block; font-size: 22pt; color: # ccccff; Background-color: Red}
Age {display: block; font-size: 12pt}
Connect CSS in data. xml
<? XML-stylesheet href = "css.css" type = "text/CSS"?>
No. 4 -- display with XSL (not to mention)
No. 5 -- you can use the xmldom object of ASP, but it is not the scope discussed today.

***********************
* XML data operations
***********************
Use vbs or JS

For example
<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>
The above No. 2 can be displayed by page:
<Button onclick = "xmltable. firstpage ()"> first </button>
<Button onclick = "xmltable. previouspage ()"> Prev </button>
<Button onclick = "xmltable. nextpage ()"> next </button>
<Button onclick = "xmltable. lastpage ()"> last </button>

******************
* Query XML files
******************
Connect to the XML document: <XML id = xmldata src = data. xml> </XML>
<Input type = button value = SEARCH name = btnsearch>
Construct vbs query Functions

< 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> <B> QQ: </B> "   & Xmldata. recordset ( " Qq " ). Value &   " </TD> <B> mail: </B> "   & Xmldata. recordset ( " Email " ). Value &   " </TD> <B> message: </B> "   & Xmldata. recordset ( " Message " ). Value & " </TD> </tr> <br>"
 
End   If
Xmldata. recordset. movenext ()
Next
End sub
</ Script >


********************
XML files can be added, deleted, modified, and static html files.
You can use FSO of ASP or (required) Microsoft. xmldom object.

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.