Link to home
Start Free TrialLog in
Avatar of sLso
sLso

asked on

Read XML data thru actionscript

I'm writing the actionscript to read an external xml file. However, the nodeType of the data are type 1. Therefore, the nodeValue become "null".

What can I do if I want to get the data correctly without the tag ?

my actionscipt like this :

     /* xml loaded */
     ...
     var Sales = this.childNodes;
     
     for(i = 0; i < Sales.length; i++) {
          trace(Sales[i].childNodes[i]);
          trace(Sales[i].childNodes[i].nodeName);
          trace(Sales[i].childNodes[i].nodeType);
          trace(Sales[i].childNodes[i].nodeValue);
     }
It get the correct nodeName and return the nodeType as 1. If I want to get the data correctly, the nodeType need to be 3. How to make it ?

this is part of the xml file :

     <Sales>
          <CompanyName>ABC</CompanyName>
          <SalesName>John</SalesName>
          <Tel>1234 5678</Tel>
          <Mobile>1234 5678</Mobile>
          <Fax>1234 5678</Fax>
          <Email>john@abc.com</Email>
          <Other>Peripherals</Other>
     </Sales>      
     <Sales>
          ...
     </Sales>      

Would anyone know how's to do that ??

Many thanks,
sL
Avatar of blue-genie
blue-genie
Flag of South Africa image

Hi, i'm not sure I understand your problem.

"However, the nodeType of the data are type 1. Therefore, the nodeValue become "null".
It get the correct nodeName and return the nodeType as 1. If I want to get the data correctly, the nodeType need to be 3.

i don't understand any of that, what exactly are  you trying to achieve and return.
what are all your trace statements outputting in comparison to what you want it to output?

blu.
Avatar of sLso
sLso

ASKER

I just want to output the data only, without the tags.

that's mean,
     <Sales>
          <CompanyName>ABC</CompanyName>
          <SalesName>John</SalesName>
          <Tel>1234 5678</Tel>
          <Mobile>1234 5678</Mobile>
          <Fax>1234 5678</Fax>
          <Email>john@abc.com</Email>
          <Other>Peripherals</Other>
     </Sales>      
     <Sales>

now, it can return the nodeName "CompanyName", and nodeType as 1 as well. I also want it can return the data "ABC" only.
ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sLso

ASKER

Thx a lot, blu. !!
Thanks...blu..(Even I had this problem..but I skipped the problem and used alternate method with changing the structure of the XML file)
u're both very welcome.