Use ASP + XML to create a message book-3

Source: Internet
Author: User
Tags chr
Use ASP + XML to create a message book-3
(01-6-6 15)
6. Create a new message writing program (PostNew. asp)
The function of this file is to write a new XML node. First, create an XML object and read the XML into the memory. The appendChild () method is used.
Add the generated XML node.
<%
Username = request. form ("username ")
If username <> "" then
Fromwhere = request. form ("fromwhere ")
Homepage = request. form ("homepage ")
Email = request. form ("email ")
Text = request. form ("text ")
Text = replace (text, "<", "<")
Posttime = now ()
StrSourceFile = Server. MapPath ("/") & "List. xml"
'Obtain the path of the XML file. The path varies depending on your virtual directory.
Set objXML = Server. CreateObject ("Microsoft. XMLDOM ")
'Create an XML object
ObjXML. load (strSourceFile)
'Read XML files into memory
Set objRootlist = objXML.doc umentElement. selectSingleNode ("NewList ")
'Select the <NewList> node
If objRootlist. hasChildNodes then
'Determine whether <NewList> has subnodes (because if each <NewList> operation has no subnodes,
'If no judgment is added, an error will be reported when the first operation is successful.
Id = objRootlist. lastchild. firstchild. text + 1
'Obtain the ID number of the child node to be inserted. The ID number is the first child node (firstchild) of the last child node (lastchild) of <NewList>)
ID number plus 1 (here we increase progressively according to the ID number of the relational database)
Else
'If there is no word subnode, it is the first time the message ID is set to 1
Id = 1
End if
Brstr = chr (13) & chr (10) & chr (9)
'To insert nodes in the XML file with line breaks and spaces arranged neatly
'(Of course you don't need to use it to make XML data look good)
XMLnode = brstr & "<list>" & brstr &_
"<Id>" & id & "</id>" & brstr &_
"<Username>" & username & "</username>" & brstr &_
"<Fromwhere>" & fromwhere & "</fromwhere>" & brstr &_
"<Posttime>" & Posttime & "</Posttime>" & brstr &_
"<Homepage>" & homepage & ""<Email>" & email & "</email>" & brstr &_
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.