Search  

HOW TO GET VALUES FROM AN XML FILE?

HomeForumsFlash Discussionhow to get values from an xml file?
Default-profile rajkir
3 posts

hi everyone,

I have a problem with loading values from xml file.
the xml file has cost of items.

xml file name: item.xml

30 40 I have tried a lot with actionscript but I failed to get the values from xml file to my flash file so that I can do some calculations according to the values.

Can anyone tell me what will be the actionscript code for getting value from xml file to flash file.

I am using actionscript 2.0

any help will be a lot for me.

thanks in advance.

Posted about 1 month ago
Default-profile rajkir
3 posts

the xml is like this. file name is item.xml

“fruits” ” cost ” apple 40 apple grapes 30 grapes cost fruits

I have not included tags as including them the details are not displaying properly.

thanks

Posted about 1 month ago
37144 rondog
154 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars Bought between 10 and 49 items

Its hard to help you with no code. Please give us a link to your XML file because depending on how its structured, it will change the way the AS has to be written.

Posted about 1 month ago
Default-profile rajkir
3 posts

”< fruits>”

“ ””22”“ “

24 Posted about 1 month ago
37144 rondog
154 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars Bought between 10 and 49 items
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
    var fruitLength:Number = xml.firstChild.childNodes.length;
    for(var i = 0;i < fruitLength; i++)
    {
        var fruit = xml.firstChild.childNodes[i].firstChild.nodeValue;
        trace(fruit);
    }
};
xml.load("fruits.xml");
Posted about 1 month ago
38704 URanimEnigma
732 posts
Exclusive author Author was featured Sold between 1 000 and 5 000 dollars Bought between 50 and 99 items

I think he’s speaking in code. It might just be a test.

Posted about 1 month ago
37144 rondog
154 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars Bought between 10 and 49 items

haha he messaged me the real thing over email

Posted about 1 month ago
38812 Yvo
113 posts
Exclusive author Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

Maybe useful: Read in values are still string values. In order to use them in calculations, make sure your set them as a number: var costNumber = Number(cost);

With cost being the read in variable from the xml file.

Posted about 1 month ago