Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can i update xml file click on the button

    this is my function...plz help me.....
    function upDate()
    {
    xmlhttp.open("GET","xmlf/emp.xml",false);
    xmlhttp.send(null);
    xmlDoc=xmlhttp.responseXML;
    var x=xmlDoc.getElementsByTagName("Student");
    for(i=0;i<x.length;i++)
    {
    if(document.getElementById("se").value == x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue){
    var a = x[i].getElementsByTagName("Address")[0].childNodes[0].nodeValue = document.getElementById("address").value;
    alert(x[i].getElementsByTagName("Address")[0].childNodes[0].nodeValue = document.getElementById("address").value);
    alert("In");
    }
    }
    alert("end");
    }

  • #2
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
    	var xmlhttp = new XMLHttpRequest(); // You must Initialize
    	xmlhttp.open("GET","x.xml",false); // async is false, which is fine, but try async sometime
    	xmlhttp.send(); // no need for null
    	var x=xmlhttp.responseXML.getElementsByTagName("Student"); // only need one variable
    	for(var i=0,j=x.length;i<j;i++){ // DECLARE VARIABLE if "i" is defined in window then it'll be overwritten
               Code in for loop should be fine 
            }
    When it comes to reponseXML your XML MUST be VALID to your browser expecially. This code was tested on Chrome 22.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •