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

  • Home
  • SEARCH
  • 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 7530211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:50:57+00:00 2026-05-30T04:50:57+00:00

Hello guys i’m having one hell of a time trying to parse an xml

  • 0

Hello guys i’m having one hell of a time trying to parse an xml string. The string look like this.

             <sheetData>
                <row r="1" spans="1:12" x14ac:dyDescent="0.25">
                  <c r="A1">
                    <v>1</v>
                  </c>
                  <c r="B1" t="s">
                    <v>3</v>
                  </c>
                  <c r="C1" t="s">
                    <v>2</v>
                  </c>
                  <c r="F1" t="s">
                    <v>0</v>
                  </c>
                  <c r="L1" t="s">
                    <v>1</v>
                  </c>
                </row>
                <row r="2" spans="1:12" x14ac:dyDescent="0.25">
                  <c r="A2">
                    <v>1</v>
                  </c>
                  <c r="B2" t="s">
                    <v>4</v>
                  </c>
                </row>
                <row r="4" spans="1:12" x14ac:dyDescent="0.25">
                  <c r="I4">
                    <v>7</v>
                  </c>
                </row>
              </sheetData>

i have searched and searched but what i keep finding is how to read and xml file using jquery or javascript which do not seem to meet my requirements.

Here is the code i have created and try but i keep failing.

                var len = xmlDoc2.getElementsByTagName("row")[0].childNodes.length;

                  for (var i=0; i < (TotalSheetNodes*len); i++){


                    mysheet.innerHTML +=(xmlDoc2.getElementsByTagName("c")[i].getAttribute("r") ) + "</br>";

                    var v1 = (xmlDoc2.getElementsByTagName("c")[i].getAttribute("r") );


                    /*if the element does not have an attribute of t then add it to then add it to the dictionary*/
                    if (xmlDoc2.getElementsByTagName("c")[i].getAttribute("t") == null)
                    {   
                        var v2 = xmlDoc2.getElementsByTagName("v")[i].childNodes[0].nodeValue

                            Jcell.Dictionary[v1]= v2

                    }
                    //else addid to the sheet element so we can extract the value later  from shared string.
                    else{
                    Jcell.Sheet[(v1)] = v1;

                    }

its failing because of this line.

                var len = xmlDoc2.getElementsByTagName("row")[0].childNodes.length;

so here is my basic question whats the easiest way to get all the child nodes under “row”? In addition i like to make a decision that if the child node has an attribute of “T”
i want to assign the value to a different object variable.
Your response would be greatly appreciated.
I would really like to do this with plain old JavaScript and prefer to stay away from any library’s.

  • 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-30T04:50:58+00:00Added an answer on May 30, 2026 at 4:50 am

    Are you sure that your xmlDoc2.getElementsByTagName("row") has at least one result? Else, the syntax seems to be fine.

    Also, there’s much initialisation missing in your script snippet, without which we won’t be able to help you.

    • xmlDoc2 – is this an well-parsed XML document object (or an error message?)
    • TotalSheetNodes is what?
    • mysheet seems to be an HTML element?
    • what is JCell? It seems not to be related to the question.

    EDIT:

    To traverse (seems to be the right word, not “parse”) your XML document you should loop through each NodeList on its own. Thats possible, every element inherits the Node interface, not only the xml document object – as you seem to believe.

    Also, you should not have to count the rows, as you are only interested in cs. A big mistake seems to be the aritmethic approximation for the number of cs in your (whole) document by multilpying the number or rows with the number of c elements in the first row – your xml source proves this is wrong.

    var rows = xmlDoc2.getElementsByTagName("row");
    for (var i=0, l=rows.length; i<l; i++) {
        var row = rows[i];
        var cs = row.getElementsByTagName("c");
        for (var j=0, m=cs.length; j<m; j++) {
            var c = cs[j];
            var t = c.getAttribute("t");
            var v = c.getElementsByTagName("v")[0]; // throws an error if there is no "v"
    
            // do whatever you want with row, c, t and v
        }
    }
    

    As you don’t use row in your example above, you might just omit the outer loop and use

    var cs = xmlDoc2.getElementsByTagName("c");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Guys I am trying to figure out why i am gettings this error
Hello guys I'm looking for a way on the iPhone to parse an XML
Hello guys this is a very simplified version of my table: I will like
Hello guys I need to pass a string array over to a setter that
Hello guys. I trying set EditText to input only numbers and point ( .
Hello guys Im having a problem in how to clear the previous activity after
Hello guys Im using advance notification manager this is the code Notification note =
Hello guys can anyone help me with the issue im having with installation of
Hello Guys I've a request for you.I've Drinks, Menus and Users routes. I've this
Hello guys on my blog I use this script: jQuery(document).ready(function () { jQuery(.postbox).hover(function ()

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.