This example shows how to obtain and manipulate submitted XForms instance data within an Active Server Page. Our ASP is called EchoPerson.asp, which takes the submitted XML and outputs it to the browser in a tabular format. (The full ASP code is available here.)
In the ASP, to get hold of the XML instance data, we create an MSXML DOMDocument and load the HTTP Request (the submitted XML) into it, using the load method, as follows:
...
var oXML = new ActiveXObject("MSXML2.DOMDocument");
oXML.load(Request);
...
Now we have the instance data in the DOMDocument we can retrieve values from it to set our script variables. Using the selectSingleNode XPath function we return a node from which we can get the value:
...
var oFirstName = oXML.selectSingleNode("/person/firstname");
var sFirstName = oFirstName.text;
var oSurname = oXML.selectSingleNode("/person/surname");
var sSurname = oSurname.text;
...
Now we have the instance data values stored into our JavaScript variables we can do as we want with them, in this case just format them for display using an HTML table:
...
var sHTML = "| First name : | " + sFirstName + " |
| Surname : | " + sSurname + |
Once we have built up the complete HTML string we return it to the browser:
...
Response.Write(sHTML);
To try this for yourself:
1. Extract the person.html and EchoPersonDataASP.asp files from the xfserverscripts.zip (see 'Prerequisites') to the root directory of your default IIS site.
2. Open the person.html file in notepad, or other text editor, and change the submission element action attribute to "EchoPersonDataASP.asp".
3. Open up Internet Explorer and go to http://localhost/person.html
4. Change any data and submit the form.

Recent comments
7 weeks 3 days ago
9 weeks 2 days ago
16 weeks 2 days ago
40 weeks 4 hours ago
49 weeks 4 days ago
1 year 48 weeks ago
1 year 48 weeks ago
2 years 1 day ago
2 years 1 week ago
2 years 1 week ago