Generating XML as Text through ASP


Form for collecting information:

<html><head><title>Forms to XML</title></head>
<body><h1>Address Collector</h1>
<form action="formxml.asp" method="POST">
<p>First Name:<input type="text" name="firstname" size="20" /></p>
<p>Last Name:<input type="text" name="lastname" size="30" /></p>
<p>Address 1:<input type="text" name="address1" size="40" /></p>
<p>Address 2:<input type="text" name="address2" size="40" /></p>
<p>City:<input type="text" name="city" size="25" /> State/Province:<input type="text" name="state" size="25" /></p>
<p>ZIP/Postal Code:<input type="text" name="postalcode" size="15" /> Country:<input type="text" name="country" size="25" /></p>
<p><input type="submit" name="Submit" /></p>
</form>

</body></html>

ASP Script for returning it as XML:

<%@LANGUAGE="JavaScript"%>
<%Response.ContentType="application/xml";%>
<?xml version="1.0"?>
<record>
<name><firstname><%=Request.Form.item("firstname")%></firstname> <lastname><%=Request.Form.item("lastname")%></lastname></name>
<address><line1><%=Request.Form.item("address1")%></line1>
<line2><%=Request.Form.item("address2")%></line2>
<city><%=Request.Form.item("city")%></city>
<state><%=Request.Form.item("state")%></state>
<postalcode><%=Request.Form.item("postalcode")%></postalcode>
<country><%=Request.Form.item("country")%></country>
</address>
</record>

<Origin Page   TOC

Copyright 2000 Simon St.Laurent