Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

XML path handeling (NaN problem)...

Community Beginner ,
Feb 18, 2013 Feb 18, 2013

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

TOPICS
ActionScript
527
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Feb 18, 2013 Feb 18, 2013

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

Translate
LEGEND ,
Feb 18, 2013 Feb 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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 18, 2013 Feb 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 18, 2013 Feb 18, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2013 Feb 18, 2013
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines