B
bennett.matthew
Hello all,
This is probably an elementary (no pun intended) question, but I've
spent all afternoon on it and it's driving me crazy.
I have a function which dynamically adds to a table. It receives a
variable which basically encapsulates this:
<div id="tableid">
<tr>
<td>col1</td>
<td>col2</td>
...
</tr>
...
</div>
It's worth nothing that the incoming variable is a product of XSLT
transformation, so I think it's technically an XML DOM element
(although I'm not too sure on the difference between the XML DOM and
the HTML DOM).
On the incoming variable, I do getElementsByTagName("tr") and -("td")
to get NodeLists of the rows and columns respectively. To insert them
into the table, I create new tr and td elements, then copy the value
over, like this:
//stuff to get a column
trs = getElementsByTagName("tr");
tds = trs.getElementsByTagName("td");
thiscol = tds[j];
//stuff to copy the column value
new_tr = document.createElement("tr");
new_td = document.createElement("td");
new_td.innerHTML = thiscol.xml
The .xml part is a Microsoft creation, so the only works in Internet
Explorer. In anything else the column value is rendered as 'undefined'.
I'm trying to make things work in Mozilla too, but an Element node
(thiscol.nodeType gives me '1') doesn't have nodeValue implemented.
InnerHTML and OuterHTML are not implemented either.
How on earth are you supposed to extract a value from an XML node if
nodeValue is not defined? Am I going about things in the wrong way?
Many thanks in advance,
Matt.
This is probably an elementary (no pun intended) question, but I've
spent all afternoon on it and it's driving me crazy.
I have a function which dynamically adds to a table. It receives a
variable which basically encapsulates this:
<div id="tableid">
<tr>
<td>col1</td>
<td>col2</td>
...
</tr>
...
</div>
It's worth nothing that the incoming variable is a product of XSLT
transformation, so I think it's technically an XML DOM element
(although I'm not too sure on the difference between the XML DOM and
the HTML DOM).
On the incoming variable, I do getElementsByTagName("tr") and -("td")
to get NodeLists of the rows and columns respectively. To insert them
into the table, I create new tr and td elements, then copy the value
over, like this:
//stuff to get a column
trs = getElementsByTagName("tr");
tds = trs.getElementsByTagName("td");
thiscol = tds[j];
//stuff to copy the column value
new_tr = document.createElement("tr");
new_td = document.createElement("td");
new_td.innerHTML = thiscol.xml
The .xml part is a Microsoft creation, so the only works in Internet
Explorer. In anything else the column value is rendered as 'undefined'.
I'm trying to make things work in Mozilla too, but an Element node
(thiscol.nodeType gives me '1') doesn't have nodeValue implemented.
InnerHTML and OuterHTML are not implemented either.
How on earth are you supposed to extract a value from an XML node if
nodeValue is not defined? Am I going about things in the wrong way?
Many thanks in advance,
Matt.