XML Template:
<?xml version="1.0"?> <letter> <entry /> <greetings>Dear Fool,</greetings> <p>You have won a million, trillion dollars!!!!! In laminated game money, that is. Please contact us to collect your prize at +1 888 555 1212. Shipping and handling fees of up to ten thousand dollars may be required to collect your prize.</p> <signoff>Hahahaha!</signoff> <signature>the prize committee (we prys your money away from you!)</signature> </letter>
ASP Code for combining the template with the form results:
<%@LANGUAGE=JavaScript%> <%Response.ContentType="application/xml"; sourceFile=Server.MapPath("prizewin.xml"); var myDoc=Server.CreateObject("Microsoft.XMLDOM"); myDoc.async=false; myDoc.load(sourceFile); var rootNode=myDoc.documentElement; var entry=rootNode.firstChild ; var nameNode=myDoc.createElement("name"); var firstNameNode=myDoc.createElement("firstname"); var firstNameText=myDoc.createTextNode(Request.Form.item("firstname")); firstNameNode.appendChild(firstNameText); var lastNameNode=myDoc.createElement("lastname"); var lastNameText=myDoc.createTextNode(Request.Form.item("lastname")); lastNameNode.appendChild(lastNameText); nameNode.appendChild(firstNameNode); nameNode.appendChild(lastNameNode); entry.appendChild(nameNode); var addressNode=myDoc.createElement("address") var line1Node=myDoc.createElement("line1") var line1Text=myDoc.createTextNode(Request.Form.item("address1")); line1Node.appendChild(line1Text); addressNode.appendChild(line1Node); var line2Node=myDoc.createElement("line2") var line2Text=myDoc.createTextNode(Request.Form.item("address2")); line2Node.appendChild(line2Text); addressNode.appendChild(line2Node); var cityNode=myDoc.createElement("city") var cityText=myDoc.createTextNode(Request.Form.item("city")); cityNode.appendChild(cityText); addressNode.appendChild(cityNode); var stateNode=myDoc.createElement("state") var stateText=myDoc.createTextNode(Request.Form.item("state")); stateNode.appendChild(stateText); addressNode.appendChild(stateNode); var postalNode=myDoc.createElement("postalcode") var postalText=myDoc.createTextNode(Request.Form.item("postalcode")); postalNode.appendChild(postalText); addressNode.appendChild(postalNode); var countryNode=myDoc.createElement("country") var countryText=myDoc.createTextNode(Request.Form.item("country")); countryNode.appendChild(countryText); addressNode.appendChild(countryNode); entry.appendChild(addressNode); Response.write(myDoc.xml) %>
Copyright 2000 Simon St.Laurent