Client
<script language= "JavaScript" >//Generate XML File function Getallformdata () {var strxml = "<client>\r\n<form Data>\r\n "; Strxml + = "<UserName>bccu</UserName>" strxml + = "<Age>25</Age>"; Strxml + = "</FormData>\r\n</Client>" return strxml; }///Send XML document function Send (Str,url) {var Http = new ActiveXObject ("Microsoft.XMLHTTP") Http.open ("POST") to the server , Url,false) http.send (STR) return http.responsetext; }///Get the value of the section specified 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) re Turn (FALSE)} else {var node = Dom.documentElement.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-side (Test.cs)
System.IO.Stream Stream = request.inputstream System.Xml.XmlDocument doc = new XmlDocument (); Try { doc. Load (stream); Load the XML document sent over} 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); } The doc is processed and output to return to the client (omitted here) Response.Write ("")