5 Replies Latest reply on Jul 26, 2006 3:58 AM by Peter Lorent

    .nodeValue returning null

    timothytrice
      XML File

      My actionscript is returning the right node...this isn't a problem of trying to find it or anything like that (have had that problem). The problem is that I'm accessing it like .childNodes[1].nodeValue for date, time, lat, lon, etc. But it returns null. I have to use string functions to separate the tags. I know there is an easier way. Is my XML not formatted right? Any other suggestions on what I might be missing?

      Thanks,

      Tim
        • 1. Re: .nodeValue returning null
          blemmo Level 1
          When the nodeValue is null, it's very likely that the node isn't a textnode, so I guess youre not accessing the right node. Try tracing the nodeName property of the node you access and see if it's the right.
          If you can change the xml format you could think about having the data nodes as attributes for the 'point' nodes. Somewhere I read that attributes get parsed faster than child nodes, and you could access them by names instead of numbers, like dateX = myNode.attributes.date;

          cheers,
          blemmo
          • 2. Re: .nodeValue returning null
            timothytrice Level 1
            I get that if it's not a text node, nodeValue will return null, nodeName will return a value; if not...vice versa. What I'm trying to figure out is what is wrong with my XML that Flash doesn't consider it a text node! All tutorials I've read regarding Flash have XML constructed in much the same way and they're using the same methods. Yes, if I use nodeName, it returns the node names I'm trying to use. Am I going to have to use attributes? Seems to me I should get the same issues!

            Thanks again,

            Tim
            • 3. Re: .nodeValue returning null
              Peter Lorent Level 2
              Parsing should be:
              //outputs 109.9
              trace(this.firstChild.childNodes[1].childNodes[3].firstChild.nodeValue);
              • 4. Re: .nodeValue returning null
                Level 7
                Another one of those flash oddities. When flash parses text in nodes, it
                wraps the text in child text nodes.

                So

                <point>
                <date>07/17</date>
                <time>0300Z</time>
                </point>

                becomes

                <point>
                <date><hiddentextnode>07/17</hiddentextnode></date>
                <time><hiddentextnode>0300Z</hiddentextnode></time>
                </point>

                var dateValue = pointNode.childNodes[0].firstChild.nodeValue;
                var timeValue = pointNode.childNodes[1].firstChild.nodeValue;

                etc...



                "timothytrice" <webforumsuser@macromedia.com> wrote in message
                news:ea6hhe$n86$1@forums.macromedia.com...
                > I get that if it's not a text node, nodeValue will return null, nodeName
                will
                > return a value; if not...vice versa. What I'm trying to figure out is
                what is
                > wrong with my XML that Flash doesn't consider it a text node! All
                tutorials
                > I've read regarding Flash have XML constructed in much the same way and
                they're
                > using the same methods. Yes, if I use nodeName, it returns the node names
                I'm
                > trying to use. Am I going to have to use attributes? Seems to me I
                should get
                > the same issues!
                >
                > Thanks again,
                >
                > Tim
                >


                • 5. Re: .nodeValue returning null
                  Peter Lorent Level 2
                  See attached code for a parsing routine of your xml document (which I called test.xml).