Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3484986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:51:11+00:00 2026-05-18T10:51:11+00:00

i am trying to read the xml file but somehow i am getting this

  • 0

i am trying to read the xml file but somehow i am getting this error: Invalid number of parameters.

<script type="text/javascript"> 
//<![CDATA[ 
    if (window.XMLHttpRequest) { 
        // code for IE7+, Firefox, Chrome, Opera, Safari 
        xmlhttp = new XMLHttpRequest(); 
    } 
    else { 
        // code for IE6, IE5 
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    xmlhttp.open("GET", "employee.XML", false); 
    xmlhttp.send(); 
    xmlDoc = xmlhttp.responseXML; 

    var empid= xmlDoc.getElementsByTagName("empid"); 
    var total = placeMarks.length; 
    var names = xmlDoc.getElementsByTagName("Name"); 
    var designation= xmlDoc.getElementsByTagName("designation"); 
    var phone= xmlDoc.getElementsByTagName("phone"); 
    ..... 
</script> 

XML data:

<employee>
<emp id="1007">
<name>John Chamber</name>
<designation>Web Expert1</designation>
<phone>555-55-555</phone>
<name>John D</name>
<designation>Web123123</designation>
<phone>555-55-555</phone>
<name>Chamber</name>
<designation>Web Expert</designation>
<phone>555-55-555</phone>
<name>Thomas</name>
<designation>TESTTEST</designation>
<phone>555-55-555</phone>

</emp>
</employee>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:51:12+00:00Added an answer on May 18, 2026 at 10:51 am

    Firstly branch out your code as shown below to see if the server is responding with the correct 200 response.

                xmlhttp.open("GET", "employee.XML", false); 
                xmlhttp.send(null);
             if (xmlhttp.status==200) {
    
                          xmlDoc = xmlhttp.responseXML; 
                         var empid= xmlDoc.getElementsByTagName("emp"); 
                         var total = placeMarks.length; 
                         var names = xmlDoc.getElementsByTagName("Name"); 
                         var designation= xmlDoc.getElementsByTagName("designation"); 
                         var phone= xmlDoc.getElementsByTagName("phone"); 
                         ..... ;
              }
    
                    else if (xmlhttp.status==404) {
              alert("XML could not be found");
             }
    

    Also my suggestion is to use a javascript library like jQuery which does much of the heavy lifting for your. The whole code for creating the XHR object simply reduces to one line

    $.get(url,function(data){
                         xmlDoc = data; 
                         var empid= xmlDoc.getElementsByTagName("emp"); 
                         var total = placeMarks.length; 
                         var names = xmlDoc.getElementsByTagName("Name"); 
                         var designation= xmlDoc.getElementsByTagName("designation"); 
                         var phone= xmlDoc.getElementsByTagName("phone");
    });
    

    Finally whichever modern browser that you are using should easily be able to point out which line in the script is throwing the error. If you still face the issue please confirm which line is throwing the error.

    EDIT
    The problem scope has changed. The OP now wants to loop through the xml.
    First of all the xml needs to be designed keeping the requirements in mind. Hence it should look like this

    <employees>
     <emp id="006">
       <name>John Chamber</name>
       <designation>Web Expert1</designation>
       <phone>555-55-555</phone>
     </emp>
     <emp id="007"> 
      <name>John D</name>
      <designation>Web123123</designation>
      <phone>555-55-555</phone>
     </emp>
     <emp id="008"> 
      <name>Chamber</name>
      <designation>Web Expert</designation>
      <phone>555-55-555</phone>
     </emp>
     <emp id="009">
       <name>Thomas</name>
       <designation>TESTTEST</designation>
       <phone>555-55-555</phone>
     </emp>
    </employees>
    

    Now the javascript for parsing the xml

    var emp=xmlDoc.getElementsByTagName("emp");
    for (i=0;i<emp.length;i++) {
       var names=emp[i].childNodes[0].text;
       var designation= emp[i].childNodes[1].text;
       ......
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read xml file from vbs script. Xml is encoded in utf-8
i am trying to read a xml file with following tag, but the sax
I'm trying to read a xml file but the ajax code I have keeps
Im currently trying to read an XML file and populate an observable collection, but
I am trying to read an XML-file from another server. However the the company
I'm currently trying to read in an XML file, make some minor changes (alter
I'm trying to read a file to produce a DOM Document, but the file
I am trying to parse an xml file using XmlReader but although I am
I am trying to read an XML file using LINQ. I have had no
I'm trying to read a xml file from client. After search for it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.