3 Replies Latest reply on Jun 2, 2006 12:50 PM by NSurveyor

    structure of  xml

    icarusdown
      How do I format the structure of xml

      from:
      <root><news><title>title text</title><body>body text</body></news></root>

      to:
      <root>
      <news>
      <title>title text</title>
      <body>body text</body>
      </news>
      </root>

      //code
      var news_xml:XML = new XML();
      news_xml.ignoreWhite = true;
      AddNewsEntry();
      //
      function AddNewsEntry() {
      var newsRoot:XMLNode = news_xml.createElement("root");
      var newsNode:XMLNode = news_xml.createElement("news");
      var titleNode:XMLNode = news_xml.createElement("title");
      var bodyNode:XMLNode = news_xml.createElement("body");
      var titleText:XMLNode = news_xml.createTextNode("title text");
      var bodyText:XMLNode = news_xml.createTextNode("body text");
      //
      news_xml.appendChild(newsRoot);
      newsNode.appendChild(titleNode);
      newsNode.appendChild(bodyNode);
      newsRoot.appendChild(newsNode);
      titleNode.appendChild(titleText);
      bodyNode.appendChild(bodyText);
      }
      //
      trace(news_xml);