2 Replies Latest reply on Sep 13, 2007 11:35 AM by Ardy15jan

    Turning a String into XML

    Ardy15jan Level 1
      Hi, everyone!
      Dows anyone know how I can turn a String that has a XML form(for ex: "<item><subitem1>child1</subitem1><subitem2>child2</subitem2></item>") into an actual XML instance ?
      Thanks a lot!
        • 1. Re: Turning a String into XML
          injpix Level 3
          Using AS2;

          var xml_str:String = "<item><subitem1>child1</subitem1><subitem2>child2</subitem2></item>";

          // defining the XML source within the XML constructor:
          var my1_xml:XML = new XML(xml_str);
          trace(my1_xml.firstChild.nodeName); // output: item
          • 2. Re: Turning a String into XML
            Ardy15jan Level 1
            Thank you, myIP :))
            I was doing the same thing(only in AS3), but I`d always get an error and couldn`t create my XML instance. I eventualy realised that somehow my string had an extra space, or a newline, or something, right at the begining, and that was the problem...
            Thank you for your help!