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 ("")