*******************************
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.