XML is a Meta markup language based on text format, which pays attention to the description of data structure and data meaning, realizes the separation of the content and the display style (xml+xsl), and is not platform independent.
Because XML pays attention to the description of the content of the data, so it is very meaningful to retrieve the data, we will not retrieve the information that is not relevant to our request again like HTML.
On the other hand, XML file is the carrier of data, using XML as a database, no need to access any database system, we can use any Web technology to display our data, such as HTML,FLASHMX.
Thanks to the active participation of the world's major computer companies, XML is increasingly becoming a new generation of internet-based data format standards.
The following XML is used as the carrier of data to develop a walls based on XML.
First, we set up an XML file Guestbook.xml, which records the name of the message, email, web address, message content. Of course, we can also add as much information as we need to. The contents of the document are as follows:
<?xml version= "1.0" encoding= "gb2312"?>
< message book >
< message records >
< Guestbook name >kai</message person name >
< e-mail >kai@hostx.org</email >
< website >http://www.17xml.com </URL >
< message content > Mountains and mountains always love, often come to the girls do not? Ka ka: _) </message content >
</Message Record >
</Message Book >
Since many servers currently support ASP, we use the common ASP as the implementation tool, guestbook.asp files are as follows:
<% @Language = "VBScript"%>
<%
' Set the information for the Web page
Response.Buffer = True
Response.Expires =-1
' Show Message function init ()
' Www.knowsky.com
Function Init ()
Entryform ()
' Define local variables
Dim Objxml
Dim ArrNames
Dim arremails
Dim Arrurls
Dim arrmessages
' Create a XMLDOM document object for storing messages
Set objxml = Server.CreateObject ("Msxml2.domdocument")
Objxml.async = False
Objxml.load (server. MapPath ("Guestbook.xml"))
' Get the message this collection of the elements
Set arrNames = Objxml.getelementsbytagname ("Guest name")
Set arremails = Objxml.getelementsbytagname ("e-mail")
Set arrurls = objxml.getelementsbytagname ("url")
Set arrmessages = objxml.getelementsbytagname ("message content")
Response.Write "<table border= ' 0 ' width= ' 100% ' >"
Response.Write "<tr><td bgcolor= ' #00CCFF ' align= ' center ' height= ' >"
Response.Write "<b> members ' comments are as follows:</b>"
Response.Write "</td></tr>"
' Output the content of each element of the message, the latest message first show
For x=arrnames.length-1 to 0 Step-1
Response.Write "<tr><td><a Href=mailto:" & Arremails.item (x). Text & ">" & Arrnames.item ( x). Text & "</a></td></tr>"
Response.Write "<tr><td> URL: <a href=" & Arrurls.item (x). Text & "target= ' _blank ' >" & Arrurls.item (x). Text & "</a><td></tr>"
Response.Write "<tr><td> Message content:</td></tr>"
Response.Write "<tr><td bgcolor= ' #0099ff ' >" & Arrmessages.item (x). Text & "</td></tr> "
Response.Write "<tr><td> </td></tr>"
Next
Response.Write "</table>"
Set Objxml = Nothing
End Function
' function to add a message record to an XML file AddEntry ()
Function AddEntry ()
' Define local variables
Dim StrName
Dim Stremail
Dim strURL
Dim strmessage
' Get the input of the message form
StrName = Request.Form ("name")
Stremail = Request.Form ("e-mail")
strURL = Request.Form ("url")
strmessage = Request.Form ("message")
Dim Objxml
Dim Objentry
Dim objname
Dim Objemail
Dim Objurl
Dim objmessage
' Add message content to XML file
Set objxml = Server.CreateObject ("Msxml2.domdocument")
Objxml.async = False
Objxml.load (server. MapPath ("Guestbook.xml"))
Set objentry = Objxml.createnode ("element", "message Record", "")
ObjXML.documentElement.appendChild (Objentry)
Set objname = Objxml.createnode ("element", "message person's name", "")
Objentry.appendchild (objname)
Objname.text = StrName
Set objemail = Objxml.createnode ("element", "e-mail", "")
Objentry.appendchild (Objemail)
Objemail.text = Stremail
Set Objurl = Objxml.createnode ("element", "url", "")
Objentry.appendchild (Objurl)
Objurl.text = strURL
Set objmessage = Objxml.createnode ("element", "message content", "")
Objentry.appendchild (objmessage)
Objmessage.text = strmessage
Objxml.save (server. MapPath ("Guestbook.xml"))
Response.Redirect ("guestbook.asp")
End Function
' Functions to fill out and send Message forms Entryform ()
Function Entryform ()
Response.Write "<p align= ' center ' ><b>xml message This example </b></p>"
Response.Write "Response.Write "<form action=guestbook.asp?action=addentry method=post>"
Response.Write "<table border=1>"
Response.Write "<tr><td> Your name: </td><td><input type=text name= name/></td></tr > "
Response.Write "<tr><td> e-mail: </td><td><input type=text name= Email/></td></ Tr> "
Response.Write "<tr><td> your website: </td><td><input type=text name= URL/></td></tr > "
Response.Write "<tr><td> your message: </td><td><textarea name= message cols=40 Rows=5></textarea ></td></tr> "
Response.Write "<tr><td> </td><td><input type=submit value= Post message/></td></tr > "
Response.Write "</table>"
Response.Write "</form>"
End Function
%>
<title>xml Message Example </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<%
' Decide whether to send a message, and update the message
Dim A
A = Request.QueryString ("action")
If a<> "" Then
AddEntry
Else
Init
End If
%>
</body>
The above is the use of XML to develop a simple example of the message board, is completely a trigger, you can add more functions as needed, all programs in the win2000+iis5.0+ie5.5 debugging pass.