Client
<Script language = "JavaScript">
// Generate an XML file
Function getallformdata ()
{
VaR strxml = "<client> \ r \ n <formdata> \ r \ n ";
Strxml + = "<username> bccu </username>"
Strxml + = "<age> 25 </age> ";
Strxml + = "</formdata> \ r \ n </client>"
Return strxml;
}
/// Send the XML document to the server
Function send (STR, URL)
{
VaR HTTP = new activexobject ("Microsoft. XMLHTTP ")
HTTP. Open ("Post", URL, false)
HTTP. Send (STR)
Return HTTP. responsetext;
}
/// Get the value of the specified section in XML
Function getxmlnodevalue (strxml, nodename)
{
VaR dom = new activexobject ("Microsoft. xmldom ")
Dom. async = false
Dom. loadxml (strxml)
If (DOM. parseerror. errorcode! = 0)
{
Delete (DOM)
Return (false)
}
Else
{
VaR node = dom.doc umentelement. selectsinglenode ("//" + nodename );
If (node)
Nodevalue = node. text;
Delete (DOM)
Return (nodevalue );
}
}
Function Test ()
{
VaR TMP = Send (getallformdata (), "./test. aspx ");
VaR name = getxmlnodevalue (TMP, "username ");
VaR Password = getxmlnodevalue (TMP, "Age ");
}
</SCRIPT>
Server (test. CS)
System. Io. Stream stream = request. inputstream
System. xml. xmldocument Doc = new xmldocument ();
Try
{
Doc. Load (Stream); // load the XML file sent
}
Catch
{
Byte [] buffer = new byte [stream. Length];
Stream. Read (buffer, 0, buffer. Length );
String strxml = system. Text. unicodeencoding. Default. getstring (buffer, 0, buffer. Length );
Doc. loadxml (strxml );
}
// Output the doc after processing to return it to the client (omitted here)
Response. Write ("")