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.