Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Use ASP + XML to create a message book-3
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)
'If there is no word subnode, it is the first time the message ID is set to 1
Id = 1
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 &_
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.