Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 05:47
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  Web Services: XML, Soap, WSDL, UDDI, and Flash Integration (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis)
| | |-+  Select Single node from XML Tree -- Newbie
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Select Single node from XML Tree -- Newbie  (Read 5061 times)
revenekorb
Server what's that
*
Posts: 1


View Profile
« on: 03/09/08, 19:18 »

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.fla
www.i-codedesign.com/zload.xml









XML TREE Data--- Need only the label attribute and the <eb></eb> value only. To plot on the chart. The XML Tree cannot change.


Code:
<?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);
}
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 03/10/08, 02:53 »

try with firstChild.firstChild.firstChild.nodeValue
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything