简体   繁体   中英

Creating xml Document In javascript shows error

I am trying to create a xml document in Javascript . but it will not give required output

Here is my code

if(status==0)
        { 


             var objXML = new ActiveXObject("Microsoft.XmlDOM")
             objXML.async = false                
             var objXMLRoot=objXML.createElement("root")
             objXML.documentElement=objXMLRoot 

             objXMLRoot.appendChild(objXML.createElement("parentname"))
             objXMLRoot.appendChild(0).text=listid

             objXMLRoot.appendChild(objXML.createElement("childname"))
             objXMLRoot.appendChild(1).text=document.getElementById("childId").value; 

             objXMLRoot.appendChild(objXML.createElement("childstatus"))
             objXMLRoot.appendChild(2).text=ichildid;                

             AjaxSend(objXMLRoot,'100','1');
        }   

My problem : i did't get any data in my xml document . i want to get listid,childid values in my xml document any help will be appriciated

Their is some syntax error in your code

try something like below

if(status==0)
        { 


             var objXML = new ActiveXObject("Microsoft.XmlDOM")
             objXML.async = false                
             var objXMLRoot=objXML.createElement("root")
             objXML.documentElement=objXMLRoot 

             objXMLRoot.appendChild(objXML.createElement("parentname"))
             objXMLRoot.childNodes(0).text=listid

             objXMLRoot.appendChild(objXML.createElement("childname"))
             objXMLRoot.childNodes(1).text=document.getElementById("childId").value; 

             objXMLRoot.appendChild(objXML.createElement("childstatus"))
             objXMLRoot.childNodes(2).text=ichildid;                

             AjaxSend(objXMLRoot,'100','1');
        }   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM