<?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 objects to XML packets using the SimpleXMLEncoder class in Flex</title>
	<atom:link href="http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/</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: Rebe</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-7972</link>
		<dc:creator>Rebe</dc:creator>
		<pubDate>Tue, 22 Jun 2010 09:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-7972</guid>
		<description>Hi!
Great job!
But... Does it works also for private attributes?
&#039;Cause I&#039;m trying to encode some classes in XML and if they have private attributes and references to other classes it doesn&#039;t work... How could I fix this problem?
Any ideas?
Thanks so much in advance.</description>
		<content:encoded><![CDATA[<p>Hi!<br />
Great job!<br />
But&#8230; Does it works also for private attributes?<br />
&#8216;Cause I&#8217;m trying to encode some classes in XML and if they have private attributes and references to other classes it doesn&#8217;t work&#8230; How could I fix this problem?<br />
Any ideas?<br />
Thanks so much in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Similian</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-7648</link>
		<dc:creator>Similian</dc:creator>
		<pubDate>Wed, 05 May 2010 10:34:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-7648</guid>
		<description>Keith H
Peter D,

This is a great fix. And yes a very annoying &quot;Bug&quot; in Adobes Sources.
I was wondering did anyone mention this to the Adobe Team (Tracker)

Was this fixed, yet?

Regards</description>
		<content:encoded><![CDATA[<p>Keith H<br />
Peter D,</p>
<p>This is a great fix. And yes a very annoying &#8220;Bug&#8221; in Adobes Sources.<br />
I was wondering did anyone mention this to the Adobe Team (Tracker)</p>
<p>Was this fixed, yet?</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Catherine André</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-5930</link>
		<dc:creator>Catherine André</dc:creator>
		<pubDate>Mon, 05 Oct 2009 09:10:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-5930</guid>
		<description>That was   EXACTLY   what I needed. Thanks for posting your  tips. Thanks a lot.</description>
		<content:encoded><![CDATA[<p>That was   EXACTLY   what I needed. Thanks for posting your  tips. Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PhilC</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-5368</link>
		<dc:creator>PhilC</dc:creator>
		<pubDate>Wed, 26 Aug 2009 09:43:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-5368</guid>
		<description>I have a custom object and I want only some of its properties to be encoded to xml. Is there a way I can tell the encoder which properties to encode and which ones to ignore?</description>
		<content:encoded><![CDATA[<p>I have a custom object and I want only some of its properties to be encoded to xml. Is there a way I can tell the encoder which properties to encode and which ones to ignore?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2723</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Mon, 20 Oct 2008 14:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2723</guid>
		<description>Paul B. Hartzog,

Correct, it doesn&#039;t look like I use the XMLNode reference returned by the &lt;code&gt;simpleXMLEncoder.encodeValue()&lt;/code&gt; method.
I haven&#039;t looked at this code in a long time, but here&#039;s what I think is happening:
1) The first line creates a new XMLDocument object.
2) The second line creates a new SimpleXMLEncoder object and passes the XMLDocument object created in on the first line. I believe the SimpleXMLEncoder constructor sets the empty XMLDocument object as the root XML node.
3) The third line calls calls the &lt;code&gt;encodeValue()&lt;/code&gt; method on the SimpleXMLEncoder object which &quot;encodes an ActionScript object to XML using default serialization&quot;. According to the comments in the source code, the first parameter (&lt;code&gt;obj&lt;/code&gt;) is &quot;the ActionScript object to encode&quot;, the second parameter (&lt;code&gt;qName&lt;/code&gt;) is &quot;the qualified name of the child node&quot;, and the third parameter (&lt;code&gt;xmlDocument&lt;/code&gt;) is &quot;an XMLNode under which to put the encoded value&quot;.
4) The fourth line converts the XMLDocument object to an XML object.

So, if you only used the first and last line, you&#039;d always have an empty XML object. The second line creates a SimpleXMLEncoder instance which gets used in the third line to covert the specified Object and insert it into the &lt;code&gt;xmlDocument&lt;/code&gt; instance. I&#039;m guessing the magic that is happening is that the SimpleXMLEncoder is directly modifying the XMLDocument object, which is why I didn&#039;t need to use the returned XMLNode object from line 3.

If you want to see exactly what happens in the SimpleXMLEncoder class, you can check out the source code in the installed SDKs /frameworks/projects/rpc/src/mx/rpc/xml/SimpleXMLEncoder.as file.

Peter</description>
		<content:encoded><![CDATA[<p>Paul B. Hartzog,</p>
<p>Correct, it doesn&#8217;t look like I use the XMLNode reference returned by the <code>simpleXMLEncoder.encodeValue()</code> method.<br />
I haven&#8217;t looked at this code in a long time, but here&#8217;s what I think is happening:<br />
1) The first line creates a new XMLDocument object.<br />
2) The second line creates a new SimpleXMLEncoder object and passes the XMLDocument object created in on the first line. I believe the SimpleXMLEncoder constructor sets the empty XMLDocument object as the root XML node.<br />
3) The third line calls calls the <code>encodeValue()</code> method on the SimpleXMLEncoder object which &#8220;encodes an ActionScript object to XML using default serialization&#8221;. According to the comments in the source code, the first parameter (<code>obj</code>) is &#8220;the ActionScript object to encode&#8221;, the second parameter (<code>qName</code>) is &#8220;the qualified name of the child node&#8221;, and the third parameter (<code>xmlDocument</code>) is &#8220;an XMLNode under which to put the encoded value&#8221;.<br />
4) The fourth line converts the XMLDocument object to an XML object.</p>
<p>So, if you only used the first and last line, you&#8217;d always have an empty XML object. The second line creates a SimpleXMLEncoder instance which gets used in the third line to covert the specified Object and insert it into the <code>xmlDocument</code> instance. I&#8217;m guessing the magic that is happening is that the SimpleXMLEncoder is directly modifying the XMLDocument object, which is why I didn&#8217;t need to use the returned XMLNode object from line 3.</p>
<p>If you want to see exactly what happens in the SimpleXMLEncoder class, you can check out the source code in the installed SDKs /frameworks/projects/rpc/src/mx/rpc/xml/SimpleXMLEncoder.as file.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul B. Hartzog</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2725</link>
		<dc:creator>Paul B. Hartzog</dc:creator>
		<pubDate>Mon, 20 Oct 2008 05:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2725</guid>
		<description>Great blog, and the code above works great as is, but
I&#039;m clearly missing something here:

&lt;pre class=&quot;code&quot;&gt;
var xmlDocument:XMLDocument = new XMLDocument();
var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName, xmlDocument);
var xml:XML = new XML(xmlDocument.toString());
&lt;/pre&gt;

xmlDocument is in the first line, and gets referred to in the last line, but the objects simpleXMLEncoder and xmlNode do not get used.  Why not simply use the first line and the last line?  What additional work is happening in the middle two lines?</description>
		<content:encoded><![CDATA[<p>Great blog, and the code above works great as is, but<br />
I&#8217;m clearly missing something here:</p>
<pre class="code">
var xmlDocument:XMLDocument = new XMLDocument();
var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName, xmlDocument);
var xml:XML = new XML(xmlDocument.toString());
</pre>
<p>xmlDocument is in the first line, and gets referred to in the last line, but the objects simpleXMLEncoder and xmlNode do not get used.  Why not simply use the first line and the last line?  What additional work is happening in the middle two lines?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2729</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Tue, 30 Sep 2008 20:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2729</guid>
		<description>Thanks Peter.  Will do...
Once again, great blog and your snippets have saves me more than once.</description>
		<content:encoded><![CDATA[<p>Thanks Peter.  Will do&#8230;<br />
Once again, great blog and your snippets have saves me more than once.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2722</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Mon, 29 Sep 2008 18:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2722</guid>
		<description>Keith H,

Thanks. You can file Flex bugs/enhancement requests at: http://bugs.adobe.com/flex/
If you post the bug number here, perhaps a few of us can subscribe and/or vote on the issue.

Peter</description>
		<content:encoded><![CDATA[<p>Keith H,</p>
<p>Thanks. You can file Flex bugs/enhancement requests at: <a href="http://bugs.adobe.com/flex/" rel="nofollow">http://bugs.adobe.com/flex/</a><br />
If you post the bug number here, perhaps a few of us can subscribe and/or vote on the issue.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2721</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Mon, 29 Sep 2008 18:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2721</guid>
		<description>I came up with a nasty workaround here....but it works.
I created a non-framework copy of the SimpleXMLEncoder, renamed it and changed all the internal references.  I change the conditional on or around line 151 to the following....

I am thinking this is a bug and I will attempt to submit to Adobe.

&lt;pre class=&quot;code&quot;&gt;
    else if (typeType == CustomXMLEncoder.ARRAY_TYPE) {
        var numMembers:uint = obj.length;
        // var itemQName:QName = new QName(&quot;&quot;, &quot;item&quot;);

        for (var i:uint = 0; i  0) {
            var className:String = classNameArray[classNameArray.length -1];
            itemQName = new QName(&quot;&quot;, className.toLowerCase());
        }
        else itemQName = new QName(&quot;&quot;, &quot;item&quot;);

        encodeValue(obj[i], itemQName, myElement);
    }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I came up with a nasty workaround here&#8230;.but it works.<br />
I created a non-framework copy of the SimpleXMLEncoder, renamed it and changed all the internal references.  I change the conditional on or around line 151 to the following&#8230;.</p>
<p>I am thinking this is a bug and I will attempt to submit to Adobe.</p>
<pre class="code">
    else if (typeType == CustomXMLEncoder.ARRAY_TYPE) {
        var numMembers:uint = obj.length;
        // var itemQName:QName = new QName("", "item");

        for (var i:uint = 0; i  0) {
            var className:String = classNameArray[classNameArray.length -1];
            itemQName = new QName("", className.toLowerCase());
        }
        else itemQName = new QName("", "item");

        encodeValue(obj[i], itemQName, myElement);
    }
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith H</title>
		<link>http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/comment-page-1/#comment-2724</link>
		<dc:creator>Keith H</dc:creator>
		<pubDate>Fri, 26 Sep 2008 17:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/04/converting-objects-to-xml-packets-using-the-simplexmlencoder-class-in-flex/#comment-2724</guid>
		<description>First off your blog rocks and it is the Flex bible as far as I am concerned.

I am using the SimpleXMLEncoder class to covert objects to XML.  All is well except when dealing with types Array Collections.

If I have an array of objects who themselves have their own types, the XML that the encoder generates refers to them as items, not the type of the object within the array.  Here is an example.
Here is what I want....
&lt;pre class=&quot;code&quot;&gt;
&lt;campuses&gt;
&lt;campuse_choice&gt;
     properties here......
&lt;/campuse_choice&gt;
&lt;/campuses&gt;
&lt;/pre&gt;

What i get is.....
&lt;pre class=&quot;code&quot;&gt;
&lt;campuses&gt;
     &lt;list&gt;
       &lt;source&gt;
           &lt;item&gt;
           &lt;/item&gt;
       &lt;/source&gt;
     &lt;/list&gt;
&lt;/campuses&gt;
&lt;/pre&gt;

I looked in the SimpleXMLEncoder class and I see the line (152) that converts them to items.  any way to have it pick up the object types within the ArrayCollection?</description>
		<content:encoded><![CDATA[<p>First off your blog rocks and it is the Flex bible as far as I am concerned.</p>
<p>I am using the SimpleXMLEncoder class to covert objects to XML.  All is well except when dealing with types Array Collections.</p>
<p>If I have an array of objects who themselves have their own types, the XML that the encoder generates refers to them as items, not the type of the object within the array.  Here is an example.<br />
Here is what I want&#8230;.</p>
<pre class="code">
&lt;campuses&gt;
&lt;campuse_choice&gt;
     properties here......
&lt;/campuse_choice&gt;
&lt;/campuses&gt;
</pre>
<p>What i get is&#8230;..</p>
<pre class="code">
&lt;campuses&gt;
     &lt;list&gt;
       &lt;source&gt;
           &lt;item&gt;
           &lt;/item&gt;
       &lt;/source&gt;
     &lt;/list&gt;
&lt;/campuses&gt;
</pre>
<p>I looked in the SimpleXMLEncoder class and I see the line (152) that converts them to items.  any way to have it pick up the object types within the ArrayCollection?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

