<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Converting XML to objects using the Flex HTTPService MXML tag</title>
	<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Tue, 06 Jan 2009 00:16:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16138</link>
		<author>peterd</author>
		<pubDate>Sat, 11 Oct 2008 23:37:43 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16138</guid>
		<description>Andrew,

You could try setting the &lt;code&gt;resultFormat&lt;/code&gt; property on the HTTPService tag to "array" when loading an XML file and see what type/format of an ArrayCollection object that returns. To get at the underlying Array object, you would just access the ArrayCollection object's &lt;code&gt;source&lt;/code&gt; property.

Apart from that, if you have a specific format you want, I'd suggest just writing your own code. Take the last result from the HTTPService tag, and loop over the ArrayCollection/XML results and construct your own custom array of objects in the specific format you need.

Peter</description>
		<content:encoded><![CDATA[<p>Andrew,</p>
<p>You could try setting the <code>resultFormat</code> property on the HTTPService tag to &#8220;array&#8221; when loading an XML file and see what type/format of an ArrayCollection object that returns. To get at the underlying Array object, you would just access the ArrayCollection object&#8217;s <code>source</code> property.</p>
<p>Apart from that, if you have a specific format you want, I&#8217;d suggest just writing your own code. Take the last result from the HTTPService tag, and loop over the ArrayCollection/XML results and construct your own custom array of objects in the specific format you need.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16097</link>
		<author>Andrew</author>
		<pubDate>Thu, 09 Oct 2008 19:58:55 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16097</guid>
		<description>to simplify what I'm saying... i want to mimic the:

&lt;pre class="code"&gt;
    &#60;mx:Array id="arr"&#62;
        &#60;mx:Object label="One" data="1" /&#62;
        &#60;mx:Object label="Two" data="2" /&#62;
        &#60;mx:Object label="Three" data="3" /&#62;
        &#60;mx:Object label="Four" data="4" /&#62;
    &#60;/mx:Array&#62;
&lt;/pre&gt;

but coming from an HTTPService from a .php file outputting XML</description>
		<content:encoded><![CDATA[<p>to simplify what I&#8217;m saying&#8230; i want to mimic the:</p>
<pre class="code">
    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="One" data="1" /&gt;
        &lt;mx:Object label="Two" data="2" /&gt;
        &lt;mx:Object label="Three" data="3" /&gt;
        &lt;mx:Object label="Four" data="4" /&gt;
    &lt;/mx:Array&gt;
</pre>
<p>but coming from an HTTPService from a .php file outputting XML</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16095</link>
		<author>Andrew</author>
		<pubDate>Thu, 09 Oct 2008 18:12:00 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-16095</guid>
		<description>Peter,

I totally understand how that works... but how can I do that when I'm returning XML from a DB?

What would my XML need to look like?  Also, wouldn't I have to put the XML into a XMLListCollection or XMLList?

My XML is currently returning something like this:



    Peter
    Andrew
    ....
    and so on.....


Would I want to include the employees primary key in the XML?


    Peter
    20
    Andrew
    2


Basically, I understand the logic behind .selectedItem.... but am really confused how to work with the XML as supposed to hardcoding my Object Array.

Thanks!</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I totally understand how that works&#8230; but how can I do that when I&#8217;m returning XML from a DB?</p>
<p>What would my XML need to look like?  Also, wouldn&#8217;t I have to put the XML into a XMLListCollection or XMLList?</p>
<p>My XML is currently returning something like this:</p>
<p>    Peter<br />
    Andrew<br />
    &#8230;.<br />
    and so on&#8230;..</p>
<p>Would I want to include the employees primary key in the XML?</p>
<p>    Peter<br />
    20<br />
    Andrew<br />
    2</p>
<p>Basically, I understand the logic behind .selectedItem&#8230;. but am really confused how to work with the XML as supposed to hardcoding my Object Array.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-15975</link>
		<author>peterd</author>
		<pubDate>Thu, 02 Oct 2008 19:43:44 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-15975</guid>
		<description>Andrew,

I typically use &#60;ComboBox&#62;.selectedItem.&#60;fieldName&#62;, or, something like the following:
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&#62;

    &#60;mx:Array id="arr"&#62;
        &#60;mx:Object label="One" data="1" /&#62;
        &#60;mx:Object label="Two" data="2" /&#62;
        &#60;mx:Object label="Three" data="3" /&#62;
        &#60;mx:Object label="Four" data="4" /&#62;
    &#60;/mx:Array&#62;

    &#60;mx:ComboBox id="comboBox" dataProvider="{arr}" /&#62;
    &#60;mx:Label text="comboBox.selectedItem.label={comboBox.selectedItem.label}" /&#62;
    &#60;mx:Label text="comboBox.selectedItem.data={comboBox.selectedItem.data}" /&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Hope that helps,
Peter</description>
		<content:encoded><![CDATA[<p>Andrew,</p>
<p>I typically use &lt;ComboBox&gt;.selectedItem.&lt;fieldName&gt;, or, something like the following:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="One" data="1" /&gt;
        &lt;mx:Object label="Two" data="2" /&gt;
        &lt;mx:Object label="Three" data="3" /&gt;
        &lt;mx:Object label="Four" data="4" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ComboBox id="comboBox" dataProvider="{arr}" /&gt;
    &lt;mx:Label text="comboBox.selectedItem.label={comboBox.selectedItem.label}" /&gt;
    &lt;mx:Label text="comboBox.selectedItem.data={comboBox.selectedItem.data}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Hope that helps,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-15974</link>
		<author>Andrew</author>
		<pubDate>Thu, 02 Oct 2008 19:27:14 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-15974</guid>
		<description>Peter,

I'm having an issue with understanding Flex's HttpService calls.  I'm looking to do something similar to an HTML Select with my form.  I currently have 1 List box and 3 comboBox's receiving XML data from my MySQL DB.

It is currently just populating the Label, however when I go to insert/update to the database I want to insert the Value (or Key) and not the label.  How could I do this?  I thought if I returned the result from the HTTPService as a result it would look more like an HTML Select, however I can't think of how the combobox or list will know what to submit when a particular Label is selected... since they are usually a selectedItem or selectedIndex.

Sorry for my confusing text either way, any help would be greatly appreciated.

Andy</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I&#8217;m having an issue with understanding Flex&#8217;s HttpService calls.  I&#8217;m looking to do something similar to an HTML Select with my form.  I currently have 1 List box and 3 comboBox&#8217;s receiving XML data from my MySQL DB.</p>
<p>It is currently just populating the Label, however when I go to insert/update to the database I want to insert the Value (or Key) and not the label.  How could I do this?  I thought if I returned the result from the HTTPService as a result it would look more like an HTML Select, however I can&#8217;t think of how the combobox or list will know what to submit when a particular Label is selected&#8230; since they are usually a selectedItem or selectedIndex.</p>
<p>Sorry for my confusing text either way, any help would be greatly appreciated.</p>
<p>Andy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marco</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-12556</link>
		<author>marco</author>
		<pubDate>Thu, 08 May 2008 02:07:54 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-12556</guid>
		<description>Hi Peter 

i read the other topic on your blog, we can use the function at the below to get the xml's data on the data grid 
&lt;pre class="code"&gt;
private function resultHandler(event:ResultEvent):void	{		
	xmlData = event.result.mynode.childnode.source as Array; 
	xmlDataAC.source = xmlData;
}
&lt;/pre&gt;

but in this case the xml format is has different child node 
One
    
        image1.jpg
        image2.jpg
        image3.jpg
    

can i still use &lt;code&gt;xmlData = event.result.album.name.source as Array;&lt;/code&gt; and 
&lt;code&gt;xmlData2 = event.result.album.image.source as Array;&lt;/code&gt; to get the data ?? i have tried that they were not work. do you have any suggestion to get the data from different node easily ??  because &lt;code&gt;img0Text.text = resultObj.album.images.image[0];&lt;/code&gt; is so hard to use when my xml has alot/ unknow lenght node.</description>
		<content:encoded><![CDATA[<p>Hi Peter </p>
<p>i read the other topic on your blog, we can use the function at the below to get the xml&#8217;s data on the data grid </p>
<pre class="code">
private function resultHandler(event:ResultEvent):void	{
	xmlData = event.result.mynode.childnode.source as Array;
	xmlDataAC.source = xmlData;
}
</pre>
<p>but in this case the xml format is has different child node<br />
One</p>
<p>        image1.jpg<br />
        image2.jpg<br />
        image3.jpg</p>
<p>can i still use <code>xmlData = event.result.album.name.source as Array;</code> and<br />
<code>xmlData2 = event.result.album.image.source as Array;</code> to get the data ?? i have tried that they were not work. do you have any suggestion to get the data from different node easily ??  because <code>img0Text.text = resultObj.album.images.image[0];</code> is so hard to use when my xml has alot/ unknow lenght node.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gSOLO</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-4358</link>
		<author>gSOLO</author>
		<pubDate>Mon, 19 Nov 2007 20:37:37 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-4358</guid>
		<description>Are you using an ArrayCollection and or are you using the default makeObjectsBindable and the result contains an Array? In my case, I believe that is where it choking.</description>
		<content:encoded><![CDATA[<p>Are you using an ArrayCollection and or are you using the default makeObjectsBindable and the result contains an Array? In my case, I believe that is where it choking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larryh</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3814</link>
		<author>larryh</author>
		<pubDate>Fri, 02 Nov 2007 20:17:34 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3814</guid>
		<description>Mae and Peterd,

I'm also encountering this issue... has anyone figured why this message occurs?  Thanks!

Larry</description>
		<content:encoded><![CDATA[<p>Mae and Peterd,</p>
<p>I&#8217;m also encountering this issue&#8230; has anyone figured why this message occurs?  Thanks!</p>
<p>Larry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3028</link>
		<author>peterd</author>
		<pubDate>Fri, 28 Sep 2007 16:22:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3028</guid>
		<description>mae,

Yeah, I'm seeing the same error (End of File). Let me know what you find out from Darron.

Peter</description>
		<content:encoded><![CDATA[<p>mae,</p>
<p>Yeah, I&#8217;m seeing the same error (End of File). Let me know what you find out from Darron.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mae</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3021</link>
		<author>mae</author>
		<pubDate>Fri, 28 Sep 2007 13:15:32 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-3021</guid>
		<description>Peter,

I'm getting the following error with Darron's code (I emailed him as well).
&lt;blockquote&gt;
Error #2030: End of file was encountered.

In ByteArray/readObject()
&lt;/blockquote&gt;

I'm returning an object from an ASP.Net Web service.

Any ideas? My &lt;code&gt;resultFormat&lt;/code&gt; is object.

Thanks.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I&#8217;m getting the following error with Darron&#8217;s code (I emailed him as well).</p>
<blockquote><p>
Error #2030: End of file was encountered.</p>
<p>In ByteArray/readObject()
</p></blockquote>
<p>I&#8217;m returning an object from an ASP.Net Web service.</p>
<p>Any ideas? My <code>resultFormat</code> is object.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
