<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Converting XML to objects using the Flex HTTPService MXML tag</title>
	<atom:link href="http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: hIUG</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/comment-page-1/#comment-10208</link>
		<dc:creator>hIUG</dc:creator>
		<pubDate>Wed, 30 Nov 2011 16:05:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-10208</guid>
		<description>Excelent!! thanks Peter, i have a little question (too late XD):

if on the xml file i have more than one album, something like:



    One
    
        image1.jpg
        image2.jpg
        image3.jpg
    


    Two
    
        asdf.jpg
        qwer.jpg
        zcxv.jpg
    



How could i acces to the album Two, image 3???
How does the object would be?

Maybe something like:
resultObj.albums.album[2].images.image[3]; ?????

thanks.</description>
		<content:encoded><![CDATA[<p>Excelent!! thanks Peter, i have a little question (too late XD):</p>
<p>if on the xml file i have more than one album, something like:</p>
<p>    One</p>
<p>        image1.jpg<br />
        image2.jpg<br />
        image3.jpg</p>
<p>    Two</p>
<p>        asdf.jpg<br />
        qwer.jpg<br />
        zcxv.jpg</p>
<p>How could i acces to the album Two, image 3???<br />
How does the object would be?</p>
<p>Maybe something like:<br />
resultObj.albums.album[2].images.image[3]; ?????</p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharan</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/comment-page-1/#comment-8086</link>
		<dc:creator>Sharan</dc:creator>
		<pubDate>Thu, 08 Jul 2010 07:43:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-8086</guid>
		<description>Thank you so much for this example.... I was struggling to get the datas in dataGrid.... Now im clear. Thanq.</description>
		<content:encoded><![CDATA[<p>Thank you so much for this example&#8230;. I was struggling to get the datas in dataGrid&#8230;. Now im clear. Thanq.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/comment-page-1/#comment-6656</link>
		<dc:creator>Amit</dc:creator>
		<pubDate>Tue, 22 Dec 2009 18:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-6656</guid>
		<description>Hi,
Nice tutorial. But I also want to validate my XML against a given XSD schema. Could you please tell me about how to do that.

Thanks,
Amit.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Nice tutorial. But I also want to validate my XML against a given XSD schema. Could you please tell me about how to do that.</p>
<p>Thanks,<br />
Amit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/comment-page-1/#comment-5952</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Thu, 08 Oct 2009 01:55:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-5952</guid>
		<description>@Simon,

Try this:
&lt;pre lang=&quot;actionscript3&quot;&gt;
private function serv_result(evt:ResultEvent):void {
    var resultObj:Object = evt.result;
    /* Assign the values... */
    nameText.text = resultObj[&#039;album-album&#039;].name;
    img0Text.text = resultObj[&#039;album-album&#039;].images.image[0];
    img1Text.text = resultObj[&#039;album-album&#039;].images.image[1];
    img2Text.text = resultObj[&#039;album-album&#039;].images.image[2];
}
&lt;/pre&gt;

Assuming you had the following XML packet:
&lt;pre lang=&quot;xml&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;album-album&gt;
    &lt;name&gt;One&lt;/name&gt;
    &lt;images&gt;
        &lt;image&gt;image1.jpg&lt;/image&gt;
        &lt;image&gt;image2.jpg&lt;/image&gt;
        &lt;image&gt;image3.jpg&lt;/image&gt;
    &lt;/images&gt;
&lt;/album-album&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>@Simon,</p>
<p>Try this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> serv_result<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span>ResultEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> resultObj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = evt<span style="color: #000066; font-weight: bold;">.</span>result<span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #009966; font-style: italic;">/* Assign the values... */</span>
    nameText<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = resultObj<span style="color: #000000;">&#91;</span><span style="color: #990000;">'album-album'</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000066; font-weight: bold;">;</span>
    img0Text<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = resultObj<span style="color: #000000;">&#91;</span><span style="color: #990000;">'album-album'</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>images<span style="color: #000066; font-weight: bold;">.</span>image<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
    img1Text<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = resultObj<span style="color: #000000;">&#91;</span><span style="color: #990000;">'album-album'</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>images<span style="color: #000066; font-weight: bold;">.</span>image<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
    img2Text<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = resultObj<span style="color: #000000;">&#91;</span><span style="color: #990000;">'album-album'</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>images<span style="color: #000066; font-weight: bold;">.</span>image<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Assuming you had the following XML packet:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;album-album<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>One<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;images<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image1.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image2.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>image3.jpg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/image<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/images<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/album-album<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/comment-page-1/#comment-5944</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Tue, 06 Oct 2009 21:44:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-5944</guid>
		<description>Nice example.

But my XML file have hyphens in the tags.  And i cant get it to work.
How would i do if for example the album tags instead of &lt;album&gt; was &lt;album-album&gt;?</description>
		<content:encoded><![CDATA[<p>Nice example.</p>
<p>But my XML file have hyphens in the tags.  And i cant get it to work.<br />
How would i do if for example the album tags instead of &lt;album&gt; was &lt;album-album&gt;?</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-page-1/#comment-1206</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Sat, 11 Oct 2008 23:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-1206</guid>
		<description>Andrew,

You could try setting the &lt;code&gt;resultFormat&lt;/code&gt; property on the HTTPService tag to &quot;array&quot; 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&#039;s &lt;code&gt;source&lt;/code&gt; property.

Apart from that, if you have a specific format you want, I&#039;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-page-1/#comment-1208</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 09 Oct 2008 19:58:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-1208</guid>
		<description>to simplify what I&#039;m saying... i want to mimic the:

&lt;pre class=&quot;code&quot;&gt;
    &lt;mx:Array id=&quot;arr&quot;&gt;
        &lt;mx:Object label=&quot;One&quot; data=&quot;1&quot; /&gt;
        &lt;mx:Object label=&quot;Two&quot; data=&quot;2&quot; /&gt;
        &lt;mx:Object label=&quot;Three&quot; data=&quot;3&quot; /&gt;
        &lt;mx:Object label=&quot;Four&quot; data=&quot;4&quot; /&gt;
    &lt;/mx:Array&gt;
&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-page-1/#comment-1207</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 09 Oct 2008 18:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-1207</guid>
		<description>Peter,

I totally understand how that works... but how can I do that when I&#039;m returning XML from a DB?

What would my XML need to look like?  Also, wouldn&#039;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-page-1/#comment-1205</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Thu, 02 Oct 2008 19:43:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-1205</guid>
		<description>Andrew,

I typically use &lt;ComboBox&gt;.selectedItem.&lt;fieldName&gt;, or, something like the following:
&lt;pre class=&quot;code&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;

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

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

&lt;/mx:Application&gt;
&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-page-1/#comment-1204</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 02 Oct 2008 19:27:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/19/converting-xml-to-objects-using-the-flex-httpservice-mxml-tag/#comment-1204</guid>
		<description>Peter,

I&#039;m having an issue with understanding Flex&#039;s HttpService calls.  I&#039;m looking to do something similar to an HTML Select with my form.  I currently have 1 List box and 3 comboBox&#039;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&#039;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>
</channel>
</rss>

