![]() Capt. Horatio T.P. Webb | Creating XML on the Client Parks -- FALL 2000 Last Updated 12PM 9/11/2000 | |
To send XML from the client to the server, we can employ the XMLHTTP component of IE5. The following six lines of VBScript code can be used to send xml:
| 1 | Set xmlsend = CreateObject("Microsoft.XMLHTTP") |
this xmlsend object will be used to send the XML using XMLHTTP |
| 2 | xmlsend.open "GET", "http://disc-nt.../echoxml.asp", False |
this open command establishes three parameters:
|
| 3 | xmlsend.setRequestHeader "Content-type", "text/xml" |
Sets the request content-type to xml |
| 4 | xmldata="a string respresenting the xml data" |
the xml data is loaded into an arbitrary string |
| 5 | xmlsend.send xmldata |
sends the xml |
| 6 | xmlresponse = xmlsend.responseText |
receives the result of the server's response |
Note that the server-side program must be able to receive the XML file.
Click here to see the send xml work (Using XMLHTTP).
(uses XMLHTTP to send to http://disc-nt.cba.uh.edu/Students/parks/echoxml.asp
Secondly, you may send XML as standard form data. This isn't really utilizing the XML format per se, however, it does accomplish the task. The idea is to send the entire XML file contents as a single string in a form. This requires you use a single variable to hold the XML AND have a program on the other end to recognize the data as XML. I have written echoxml2.asp to accomplish this task. The program echoxml2.asp receives form data. The program assumes only one variable is sent and the value of this one variable is the XML data. The program sets the response header to content-type=text/xml and then returns the value of the variable. In IE5 or later this will result in the data being displayed on the client as an XML file. The form's method must be POST.
Click here to see this form version work.
(uses a form to send the XML to http://disc-nt.cba.uh.edu/Students/parks/echoxml2.asp and get XML back.