SoFunction
Updated on 2025-04-07

Pass Xml documents using Ajax

Client

<script language="javascript">

//Generate 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 XML documents to the server
function Send(Str,URL)  

    var Http = new ActiveXObject("") 
    ("POST",URL,false) 
    (Str) 
    return ; 


///Get the value of the section specified in XML
function GetXMLNodeValue(strXML,nodeName) 

    var Dom = new ActiveXObject("") 
    =false  
    (strXML) 
    if( != 0)  
    { 
        delete(Dom) 
        return(false) 
    } 
    else 
    { 
        var node = ("//"+nodeName); 
        if(node) 
            nodeValue = ; 
        delete(Dom) 
        return(nodeValue); 
    } 


 function Test() 
 { 
    var tmp       = Send(GetAllFormData(),"./"); 
    var name      = GetXMLNodeValue(tmp,"UserName"); 
    var password  = GetXMLNodeValue(tmp,"Age"); 
 } 
</script>


Server side ()

 stream = 
 doc = new XmlDocument(); 
try 

(stream);//Load the sent Xml document

catch 

  byte[] buffer = new byte[]; 
  (buffer,0,); 
  string strXML = (buffer,0,); 
  (strXML); 


//The doc is processed and outputs to return to the client (omitted here)

("")