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
LVL 1
sLsoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
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.
0
sLsoAuthor Commented:
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.
0
blue-genieCommented:
try this:

myXML = new XML();
myXML.load("myMenu.xml");
myXML.ignoreWhite = true;
myXML.onLoad = processXML;
function processXML() {
      wordArray = new Array();
      for (var n = 0; n<myXML.firstChild.childNodes.length; n++) {
            wordArray[n] = myXML.childNodes[0].childNodes[n].childNodes[0];
            trace(wordArray[n] add " array items");
      }
}
The trace ouput is as follows:

ABC array items
John array items
1234 5678 array items
1234 5678 array items
1234 5678 array items
john@abc.com array items
Peripherals array items


happy?

blu.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

sLsoAuthor Commented:
Thx a lot, blu. !!
0
nishasrilankanCommented:
Thanks...blu..(Even I had this problem..but I skipped the problem and used alternate method with changing the structure of the XML file)
0
blue-genieCommented:
u're both very welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.