ASP development based on XML message board _ application Skills

Source: Internet
Author: User
Tags define local

XML (extensible Markup Language) is a kind of markup language based on text format, which pays attention to the description of data structure and data meaning, realizes the separation of content and display style, 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,flash 5. 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 >
< message name > Mengxian </message name >
< email >amxh@testdomain.com</email >
< URL >http://go.163.com/~colorweb</url >
< message content > Test success!! </message content >
</message Records >
</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 Web page information Response.Buffer = True Response.Expires =-1 ' Display message function init () functions Init  () Entryform () ' Define local variable Dim objxml Dim ArrNames Dim Arremails Dim Arrurls Dim arrmessages ' Create xmldom Document object to store message Set Objxml = Server.CreateObject ("msxml2.domdocument") Objxml.async = False Objxml.load (server. MapPath ("Guestbook.xml")) ' Get the message the set of each element set arrNames = Objxml.getelementsbytagname ("Message person 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
&GT;&LT;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 shows 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 ' adds a message record to an XML file AddEntry () functions addentry () ' defines local variable D Im StrName Dim stremail Dim strURL Dim strmessage ' Get Message form input 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 Records "," "") ObjXML.documentElement.appendChild (objentry) Set objname = Objxml.createnode ("element", "message 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) o Bjmessage.text = strmessage Objxml.save (server. MapPath ("Guestbook.xml")) Response.Redirect ("guestbook.asp") End Function ' functions to fill out and send a message form entryform () function Entryform () Response.Write "<p align= ' center ' ><b>xml message This example </b></p>" Response.Write " 

The above is a simple example of using XML to develop a message board, and you can add more functionality as needed.

Related Article

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.