1 Reply Latest reply on Oct 28, 2009 3:38 AM by Revlex

    XMLList to XMLNode




      Im trying to convert a small piece of my xml file wich is loaded into a XMLList to a XMLNode but i continusely keep getting te error:


      TypeError: Error #1034: Type Coercion failed: cannot convert XML@11bb2101 element <Product> to flash.xml.XMLNode.
          at xml_data_conversion/xml_complete()[C:\Users\Rens Visser\Adobe Flash Builder Beta 2\xml_data_conversion\src\xml_data_conversion.mxml:38]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.net::URLLoader/onComplete()


      Iv'e tryed aloth of things didnt work out, searched the web came acros some pointer but did not get the problem solved.

      if some one want to help me bij poiting me in the right direction?


      here's the code:


      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="400" minHeight="300" width="400" height="300">
              import flash.net.*;
              import flash.xml.*;
              import mx.controls.*;
              private var xml_loader:URLLoader = new URLLoader();
              private var txt_loader:URLLoader = new URLLoader();
              private var element_arr:Array = new Array();
              private var processed_data:Array = new Array();
              private function init_vars(evt:Event):void
                  var naam_bedrijf:String = bedrijf_naam.text + ".txt";
                  var uri_xml:String = xml_url.text;
                  txt_loader.load(new URLRequest(naam_bedrijf));
                  xml_loader.load(new URLRequest(uri_xml));
                  xml_loader.addEventListener(Event.COMPLETE, xml_complete);
                  xml_loader.addEventListener(IOErrorEvent.IO_ERROR, xml_error);
              private function xml_error(evt:IOErrorEvent):void
                  Alert.show(evt.text ,"Foutmelding");
              private function xml_complete(evt:Event):void
                  var xml:XML = new XML(xml_loader.data);
                  var str:String = txt_loader.data;
                  element_arr = str.split(",");
              private function xml_conversion(node_xml:XMLNode):void


          <s:TextInput x="10" y="8" enabled="true" id="xml_url" text="xml.xml" width="157"/>
          <s:TextInput x="232" y="9" text="azrh" id="bedrijf_naam" enabled="true"/>
          <s:Button x="232" y="61" label="Verwerk data!!!" id="start_verwerk_data" enabled="true" click="init_vars(event)"/>
          <s:TextArea x="82" y="106" id="test_box"/>