Skip to main content
Energetic_Captain154A
Inspiring
February 18, 2013
Answered

XML path handeling (NaN problem)...

  • February 18, 2013
  • 1 reply
  • 577 views

Hello,

I have a question about XML path. I'm able to get an informations from xml file (specific numbers), however I'm not able to make a mathematic operation with it. I can trace it as a number, but when I want +/- or */ flash is complaining about that it's not a number.

VydraPrize = xml.firstChild.childNodes[0].childNodes[dayCount].childNodes[0];

* VydraPrize my variable defined as number before

**dayCount my variable

Should I understand that this is not number but some kind of object, or path?

Thanks for help

WZ

This topic has been closed for replies.
Correct answer Energetic_Captain154A

Ok I solved it, there should be actually

xml.firstChild.childNodes[0].childNodes[dayCount].childNodes[0].text() + .nodeValue then it's appearing as number.

Thank you very much anyway for inspirating looking for problem in right way : )

WZ

1 reply

Ned Murphy
Legend
February 18, 2013

xml data is normally in String form.  Try forcing it to be a Number and see if that helps...

VydraPrize = Number(xml.firstChild.childNodes[0].childNodes[dayCount].childNodes[0]);

Also, you might try tracing the follow to see what you are dealing with.  I am not an xml expert at all, but I know that my dealings with it in the past usually havve me looking for the text() of a node, not the node itself, as in...

xml.firstChild.childNodes[0].childNodes[dayCount].childNodes[0].text()

Energetic_Captain154A
Inspiring
February 18, 2013

Hmm I tried to force it but it's stil NaN.

Ye well when I'll try to trace : xml.firstChild.childNodes[0].childNodes[dayCount].childNodes[0].text() it will return me undefined. Is it a problem of my XML file?