Is it possible to pick which XML node to write to? Right now the script is currently writing into the <RSS> node. I want everything to write in the <contact> node. So the final result would be <rss><contact><name>My Name</name></contact></rss>
Here is what it currently does.
Thank you!
Here is what it currently does.
Code:
Contact.XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="/css/rss_itemcontent.css" type="text/css" media="screen"?>
<rss xmlns:content="[URL unfurl="true"]http://purl.org/rss/1.0/modules/content/"[/URL] xml:lang="fr-CA" version="2.0">
<contact></contact>
<item>
<title>My Fname</title>
<pubDate>Lname</pubDate>
<link>444 Street</link>
<description>444 Stree2</description>
<author>343-394-3049</author>
<category>jdk@email.ca</category>
</item>
</rss>
XML.asp
<%
'Declare local variables.
Dim objDom
Dim objRoot
Dim objRecord
Dim objField
Dim objFieldValue
Dim objattID
Dim objattTabOrder
Dim objPI
Dim blnFileExists
Dim x
'Instantiate the Microsoft XMLDOM.
Set objDom = server.CreateObject("Microsoft.XMLDOM")
objDom.preserveWhiteSpace = False
blnFileExists = objDom.Load(Server.MapPath("Contact.xml"))
response.write Server.MapPath("Contact.xml")
'Test to see if the file loaded successfully.
If blnFileExists = True Then
Set objRoot = objDom.documentElement
Else
'Create your root element and append it to the XML document.
Set objRoot = objDom.createElement("channel")
objDom.appendChild objRoot
End If
Dim name, phone, address, newperson
name = Request("firstName")
lname = Request("lastName")
address = Request("address1")
address2 = Request("address2")
phone = Request("phone")
email = Request("email")
Dim root
Set root = objDom.documentElement
Set newperson = objDom.createNode("element", "item", "")
Dim newname, newphone, newaddress, newdescription, newauteur, newcategory
Set newname = objDom.createNode("element", "title", "")
newname.text = name
Set newphone = objDom.createNode("element", "pubDate", "")
newphone.text = lname
Set newaddress = objDom.createNode("element", "link", "")
newaddress.text = address
Set newdescription = objDom.createNode("element", "description", "")
newdescription.text = address2
Set newauteur = objDom.createNode("element", "author", "")
newauteur.text = phone
Set newcategory = objDom.createNode("element", "category", "")
newcategory.text = email
newperson.appendChild(newname)
newperson.appendChild(newphone)
newperson.appendChild(newaddress)
newperson.appendChild(newdescription)
newperson.appendChild(newauteur)
newperson.appendChild(newcategory)
objDom.documentElement.appendChild(newperson.cloneNode(True))
'Check once again to see if the file loaded successfully. If it did
'not, that means we are creating a new document and need to be sure to
'insert the XML processing instruction.
If blnFileExists = False then
'Create the xml processing instruction.
Set objPI = objDom.createProcessingInstruction("xml", "version='1.0'")
'Append the processing instruction to the XML document.
objDom.insertBefore objPI, objDom.childNodes(0)
End If
'Save the XML document.
'objDom.save strXMLFilePath & "\" & strFileName
Set objPI = objDom.createProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'")
objDom.insertBefore objPI, objDom.childNodes(0)
objDom.save(Server.MapPath("Contact.xml"))
'Release all of your object references.
Set objDom = Nothing
Set objRoot = Nothing
Set objRecord = Nothing
Set objField = Nothing
Set objFieldValue = Nothing
Set objattID = Nothing
Set objattTabOrder = Nothing
Set objPI = Nothing
%>
Thank you!