I have this chart for my school project. I cant change the xml file, it must remain the same. I am having a problem plotting the first node <eb></eb> only. How should I select the first node. I had no problem when it was a attribute. I am a newbie. Any help would be appreciated. XML and actionscript below.
You can download the source here.
www.i-codedesign.com/ct.flawww.i-codedesign.com/zload.xmlXML TREE Data--- Need only the label attribute and the <eb></eb> value only. To plot on the chart. The XML Tree cannot change.
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Chart label="Jan 00">
<eb>1000</eb>
<ec>1200</ec>
<ee>1290</ee>
<ci>1500</ci>
</Chart>
<Chart label="Jan 01">
<eb>900</eb>
<ec>1200</ec>
<ee>1290</ee>
<ci>1500</ci>
</Chart>
</data>
Actionscript-------- Problem finding the correct code for selecting the first Node.
function LoadChartData() {
var BaseNode = thisXML.childNodes[0];
//set up arrays
var ArrLabel = new Array();
var ArrValue = new Array();
var ThisNode;
//create datasource
var ChartData = new DataProviderClass();
//get Chart Data
for (var i=0; i < BaseNode.childNodes.length; i++) {
ThisNode = BaseNode.childNodes[i];
ArrLabel[i] = ThisNode.attributes["label"];
/*problem selecting the child node for ChartValue from the <eb> value. how do you target the <eb> value only?*/
ArrValue[i] = ThisNode.attributes["ChartValue"];
ChartData.addItem({CW:ArrLabel[i], TB:ArrValue[i]});
}
MyChart.setDataProvider(ChartData);
MyChart.setLabelSource("CW");
MyChart.setValueSource("TB");
//get Chart Title
var ChartTitle;
if (BaseNode.attributes["ThisTitle"].length > 0) {
ChartTitle = BaseNode.attributes["ThisTitle"];
}
else {
ChartTitle = " ";
}
MyChart.setChartTitle(ChartTitle);
}