R
Robert Fentress
I'm loading an xml data file and then trying to take a particular node
and add it, as html, to an element on my page using inner HTML. The
xml is like what is below, with the ... representing eliminated
detail:
<?xml version="1.0" encoding="iso-8859-1"?>
<table>
<descriptions>
<fielddesc id="1">
...
</fielddesc>
...
</descriptions>
<recordset>
<record id="1">
<field id="1">1</field>
<field id="2">Hydrogen</field>
<field id="3">H</field>
<field id="4">[not applicable]</field>
<field id="5">[not applicable]</field>
<field id="6">[not applicable]</field>
<field id="7">1s<sup>1</sup></field>
</record>
...
</recordset>
</table>
The problem comes with id 7 above. I want to get everything that is
contained in that field and use it in my page so that the <sup> html
tag is used. Here are some things I've tried:
recordset = table.getElementsByTagName('recordset')[0].getElementsByTagName('record');
valueIwant = recordset[1].getElementsByTagName('field')[7].firstChild.data;
(This only gets everything up to the <sip> tag)
recordset = table.getElementsByTagName('recordset')[0].getElementsByTagName('record');
valueIwant = recordset[1].getElementsByTagName('field')[7].text;
(This only works on IE and it doesn't format the contents in the <sup>
tag)
Anybody have some suggestions on how to do what I want?
Thanks,
Rob
and add it, as html, to an element on my page using inner HTML. The
xml is like what is below, with the ... representing eliminated
detail:
<?xml version="1.0" encoding="iso-8859-1"?>
<table>
<descriptions>
<fielddesc id="1">
...
</fielddesc>
...
</descriptions>
<recordset>
<record id="1">
<field id="1">1</field>
<field id="2">Hydrogen</field>
<field id="3">H</field>
<field id="4">[not applicable]</field>
<field id="5">[not applicable]</field>
<field id="6">[not applicable]</field>
<field id="7">1s<sup>1</sup></field>
</record>
...
</recordset>
</table>
The problem comes with id 7 above. I want to get everything that is
contained in that field and use it in my page so that the <sup> html
tag is used. Here are some things I've tried:
recordset = table.getElementsByTagName('recordset')[0].getElementsByTagName('record');
valueIwant = recordset[1].getElementsByTagName('field')[7].firstChild.data;
(This only gets everything up to the <sip> tag)
recordset = table.getElementsByTagName('recordset')[0].getElementsByTagName('record');
valueIwant = recordset[1].getElementsByTagName('field')[7].text;
(This only works on IE and it doesn't format the contents in the <sup>
tag)
Anybody have some suggestions on how to do what I want?
Thanks,
Rob