RE: [xsl] HTML form contents => XML document

Subject: RE: [xsl] HTML form contents => XML document
From: "Kevin Read" <kevin@xxxxxxxxxxxxxxxx>
Date: Fri, 3 Aug 2001 04:07:48 +0930
Although not perl or php, in ASP I use the following code sets.  They may be
useful to others as well.  They look in the request object and etract the
values.

Kevin

<%
Function Form2XML
	Dim FormXML
	FormXML = "<?xml version=""1.0""?>" + chr(10)
	FormXML = FormXML & "<form>"+ chr(10)
	For Each objItem In Request.Form
		FormXML = FormXML + "<" + objItem + ">" +
ValidateXMLItemValue(Request.Form(objItem)) + "</" + objItem + ">" + chr(10)
	Next
	FormXML = FormXML + "</form>"+ chr(10)

	Form2XML = FormXML
End Function

Function Form2XMLwithSession
	Dim FormXML
	FormXML = "<?xml version=""1.0""?>" + chr(10)
	FormXML = FormXML & "<form>"+ chr(10)
	For Each objItem In Request.Form
		FormXML = FormXML + "<" + objItem + ">" +
ValidateXMLItemValue(Request.Form(objItem)) + "</" + objItem + ">" + chr(10)
	Next
	For Each objItem In Session.Contents
		If Not IsObject(Session.Contents(objItem)) and Not
IsArray(Session.Contents(objItem)) Then
			FormXML = FormXML + "<" + objItem + ">" +
ValidateXMLItemValue(Session.Contents(objItem)) + "</" + objItem + ">" +
chr(10)
		End If
	Next
	FormXML = FormXML + "</form>"+ chr(10)

	Form2XMLwithSession = FormXML
End Function

function ValidateXMLItemValue( XMLText )
	Dim objSTR
	set objSTR = CreateObject("Framework.StringFunctions")
	thisXMLText = objStr.StringReplace(XMLText, "<", "&lt;")
	thisXMLText = objStr.StringReplace(thisXMLText, "&", "&amp;")
	thisXMLText = objStr.StringReplace(thisXMLText, ">", "&gt;")
	thisXMLText = objStr.StringReplace(thisXMLText, """", "&quot;")
	thisXMLText = objStr.StringReplace(thisXMLText, "'", "&apos;")
	set objSTR = Nothing
	ValidateXMLItemValue = thisXMLText
end function

%>

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of dante
Sent: Thursday, 2 August 2001 9:32 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] HTML form contents => XML document


G'day all,

I'd like to have the contents of a form converted/exported into a xml
document
How can this be done server-side?
With PHP?
Perl/cgi?
or another method?
Has anyone seen an example of this or something similar?
See the form: http://www.vianet.net.au/~dante/xml/input_form.html

Thanks,
            Oliver Reid
            Perth, Western Australia
            dante@xxxxxxxxxxxxx
            www.vianet.net.au/~dante




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread