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].nodeNam e);
trace(Sales[i].childNodes[ i].nodeTyp e);
trace(Sales[i].childNodes[ i].nodeVal ue);
}
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</CompanyN ame>
<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
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[
trace(Sales[i].childNodes[
trace(Sales[i].childNodes[
trace(Sales[i].childNodes[
}
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</CompanyN
<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
ASKER
I just want to output the data only, without the tags.
that's mean,
<Sales>
<CompanyName>ABC</CompanyN ame>
<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.
that's mean,
<Sales>
<CompanyName>ABC</CompanyN
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
"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.