1 Reply Latest reply on Nov 7, 2006 8:30 AM by Newsgroup_User

    nodeValue

    Level 7
      Hi,

      how to parse a nodeValue out of XML Data?

      I want to store text data into an XML file and read the text between the
      open and close tag. But the structure of the xml obeject looks a bit odd
      to me when I try to parse it in Flash.

      My XML look a bit like this:

      <?xml version="1.0" encoding="UTF8"?>
      <introhead>chinese food</introhead>
      etc.

      After loading I first try to analyse the structure of the XML tree, but
      I am a bit confuzed about the structure I get.

      ...
      xmlData = this;
      for (n in xmlData.childNodes){
      obj = xmlData.childNodes[n].nodeValue;

      for (x in xmlData.childNodes[n]){
      n = xmlData.childNodes[n][x];
      trace("#" + n.nodeType + " "+ n.nodeName + " " + n.nodeValue);
      }
      trace("node " + xmlData.nodeName + " " + obj);
      }




      Any ideas?
      TIA
        • 1. Re: nodeValue
          Level 7
          I corrected my code a bit, but the main problem is still there. I can't
          get the correct way to find my node data.

          xmlData = this;
          for (n in xmlData.childNodes){
          obj = xmlData.childNodes[n].nodeValue;
          //
          for (x in xmlData.childNodes[n]){
          nd = xmlData.childNodes[n][x]
          if (typeof(nd) == "object") trace("#" + nd.nodeType + " "+ nd.nodeName
          + " " + nd.nodeValue);
          }
          trace("node " + xmlData.nodeName + " " + obj);
          }