Running through the XML tree...
Posted: Tue Dec 30, 2003 4:04 pm
I've just started using XML today so go easy on me (aohah I'm a newbie again!)
Anyway, I'm using the xmldom object to read XML files into JavaScript and I'm having trouble spliting up the info.
Here's what I've got...
XML
JAVASCRIPT
That sort of works but I'm getting both of the unit names (Xtron and SubTronix) added to the nameA variable and I'm not sure how to get them individually.
Any help would be cool.
Anyway, I'm using the xmldom object to read XML files into JavaScript and I'm having trouble spliting up the info.
Here's what I've got...
XML
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1" ?>
<modules>
<unit>
<name>Xtron</name>
<type>distortion</type>
<position>2,10</position>
</unit>
<unit>
<name>SubTronix</name>
<type>bass</type>
<position>7,13</position>
</unit>
</modules>Code: Select all
var xmlDoc=new ActiveXObject("microsoft.xmldom")
xmlDoc.async="false"
xmlDoc.load("modulelib.xml")
var nodes = xmlDoc.documentElement.childNodes
var nameA = nodes.item(0).text
var typeA = nodes.item(1).text
var positionA = nodes.item(2).textThat sort of works but I'm getting both of the unit names (Xtron and SubTronix) added to the nameA variable and I'm not sure how to get them individually.
Any help would be cool.