3 Replies Latest reply on Feb 23, 2007 6:33 AM by mxc

    xml text node problems


      I have a problem getting Flash to read in text nodes as text nodes. The xml document is standard and as I understand it a node is read as a text node if it contains text. The problem is flash returns the nodeType as 1 and not 3 for all nodes. Text can be read in from the xml document but CDATA cannot. nodeValue simply returns null or undefined.

      Has anypne else come across this? All suggestions appreciated.

      ;) michael
        • 1. Re: xml text node problems
          Ex Malterra Level 1
          without seeing your xml i can't be sure, but it sounds like you're accessing the parent node of the text, not the text itself. consider this brief xml:

          <inner>some text</inner>
          <inner><![CDATA[some other text]]></inner>

          the text that is stored in both <inner> tags, with or without the cdata tag, is considered a child of the <inner> tag. the <top> and <inner> tags are elements, type 1, and the nested text and nested cdata tag are both text, type 3. element tags have no nodevalue property but text tags do. Try the following code and you'll get this:

          1 - null
          1 - null
          3 - some text
          1 - null
          3 - some other text

          • 2. Re: xml text node problems
            mxc Level 1
            Hi and thanks for your reply, I know you are correct in your reasoning, I am somehow not hitting the correct node. I have being checking it and it looks right but I guess it must not be. I am loading in an xml file and using a loop to access the nodes.
            So I will just have to keep on trying ;)
            • 3. Re: xml text node problems
              mxc Level 1
              ok now it is solved, what I needed was a another loop to loop through the childnodes. Makes sense (I guess ;)).
              Thanks again your code put me on the right track.