[osflash] Was: XML 2 Object, Object 2 XML
John Grden
neoriley at gmail.com
Tue Mar 14 14:07:26 EST 2006
ah ok, so yes, that's what you're talking about - ok, let me give er' a go.
Back in a minute
On 3/14/06, Rafael Guédez <contacto at rafaelguedez.com> wrote:
>
> For example, with the original Alessandro code I can walk to the node
> converted to object like this:
>
> ROOT.SEC[x].SUB[x].value
>
>
> How I can do that with your object?
>
>
> Try with this XML and you will see the problem:
>
>
> <ROOT>
> <SEC>
> <SUB>1</SUB>
> <SUB>2</SUB>
> </SEC>
> <SEC>
> <SUB>3</SUB>
> <SUB>4</SUB>
> </SEC>
> <SEC>
> <SUB>5</SUB>
> <SUB>6</SUB>
> </SEC>
> </ROOT>
>
>
> regards
>
>
> Rafael
>
>
> On Mar 14, 2006, at 11:55 AM, John Grden wrote:
>
> well, an object *can't* have that same structure - it's not possible to
> have duplicate keys - hence what was wrong before. You have to create an
> array. Now, i *could* create another key called sub and make THAT an array
> - is that what you mean?
>
> let me know, I'll get it in there
>
> On 3/14/06, Rafael Guédez <contacto at rafaelguedez.com> wrote:
> >
> > Hi John,
> > I see the advance, but now is a bit confuse heheh. You can see that the
> > object lost the SUB node, the object must have the same structure like the
> > original code in the example of my first message.
> >
> >
> > regards
> >
> >
> > Rafael
> >
> >
> >
> > On Mar 14, 2006, at 8:48 AM, John Grden wrote:
> >
> > Ok, if you'll give it another shot, please download the latest.
> > http://mirror1.cvsdude.com/trac/osflash/xray/browser/downloads/FLASC/XMLObject.as?rev=119&format=raw
> >
> >
> > with this code, it traces out just fine with Xray, and I added a second
> > XML doc as a secondary test with non-array structures:
> >
> > import org.opensourceflash.data.XMLObject;
> > var xmlDoc_0:XML = new
> > XML("<ROOT><SEC><SUB>123</SUB></SEC><SEC><SUB>456</SUB></SEC><SEC><SUB>789</SUB></SEC></ROOT>");
> >
> > var xmlDoc_1:XML = new XML("<child_0 title=\"john\"
> > url=\"http://\"><prop_2>12</prop_2><prop_1>true</prop_1><prop_0><2>flasc</2><1>red5</1><0>xray</0></prop_0></child_0><stringTest>Test
> > &lt;&gt; String</stringTest><cdataTest>&lt;![CDATA[Test
> > &lt;&gt; String]]&gt;</cdataTest>");
> > var obj_0 = XMLObject.getObject(xmlDoc_0, false);
> > var obj_1 = XMLObject.getObject(xmlDoc_1, false);
> > tt(obj_0);
> > tt(obj_1);
> >
> > // traces
> >
> > (30) [object Object]:
> > ROOT =
> > SEC = 123,456,789
> > 2 = 789
> > 1 = 456
> > 0 = 123
> >
> > 123 = 123
> > 456 = 456
> > 789 = 789
> >
> >
> >
> >
> >
> > (31) [object Object]:
> > cdataTest = <![CDATA[Test <> String]]>
> > stringTest = Test <> String
> > child_0 = [object Object]
> > url = http://
> > title = john
> > prop_0 = [object Object]
> > 0 = xray
> > 1 = red5
> > 2 = flasc
> >
> > prop_1 = true
> > prop_2 = 12
> >
> > On 3/13/06, Rafael Guédez < contacto at rafaelguedez.com > wrote:
> > >
> > > Hi, reading the class I think the problem is in the line 135:
> > >
> > > var obj = p_parentObject[nodeName] = p_allArray ? [] : {};
> > >
> > >
> > > You are overwriting the same child object every time, if you see the
> > > original code you need to create an array to put inside all the childs with
> > > the same nodeName.
> > >
> > >
> > > regards
> > >
> > >
> > > Rafael
> > >
> > >
> > >
> > > On Mar 13, 2006, at 5:52 PM, Rafael Guédez wrote:
> > >
> > > Hi John,
> > >
> > > I'm testing out your class and I can't get it to work properly, I only
> > > get the last node of my xml when try to convert it to object. For example
> > > this xml structure:
> > >
> > >
> > > <ROOT>
> > > <SEC>
> > > <SUB>123</SUB>
> > > </SEC>
> > > <SEC>
> > > <SUB>456</SUB>
> > > </SEC>
> > > <SEC>
> > > <SUB>789</SUB>
> > > </SEC>
> > > </ROOT>
> > >
> > >
> > > Using LumincBox log to trace the object I get only:
> > >
> > >
> > > *INFO*:myLogger:(object) {
> > > ROOT:(object) {
> > > SEC:(object) {
> > > SUB:789
> > > }
> > > }
> > > }
> > >
> > >
> > > And with the old XML2Object from Alessandro I get it fine:
> > >
> > >
> > > *INFO*:myLogger:(object) {
> > > ROOT:(object) {
> > > SEC:(array) {
> > > 2:(object) {
> > > SUB:(object)
> > > data:(null)
> > > attributes:(object)
> > > }
> > > 1:(object) {
> > > SUB:(object)
> > > data:(null)
> > > attributes:(object)
> > > }
> > > 0:(object) {
> > > SUB:(object)
> > > data:(null)
> > > attributes:(object)
> > > }
> > > }
> > > data:(null)
> > > attributes:(object)
> > > }
> > > }
> > >
> > >
> > > *LuminicBox dont trace the complete deep of the object, but the nexts
> > > objects are there.
> > >
> > >
> > >
> > > I'm doing something wrong or is a error in the class?
> > >
> > >
> > > regards
> > >
> > >
> > > Rafael
> > >
> > >
> > >
> > >
> > > On Mar 3, 2006, at 3:18 PM, John Grden wrote:
> > >
> > > Sorry sorry, I found an issue with the xml to object where it was
> > > returning "string" as the value rather than the actual value.
> > >
> > > it's fixed at revision 110
> > > http://mirror1.cvsdude.com/trac/osflash/xray/browser/downloads/FLASC/XMLObject.as
> > >
> > > On 3/3/06, John Grden < neoriley at gmail.com > wrote:
> > > >
> > > > Ok, well, i've successfully rewritten the entire class ;)
> > > >
> > > > * No longer extends XML
> > > > * Changed to a static class
> > > > * changed package to org.opensourceflash.data since it's been
> > > > completely rewritten
> > > > * wrote new convertToObject method for converting XML to Object
> > > > * added cleanObject so that the pure object is sent back without the
> > > > root node/object reference
> > > > * included a new addStrings() method to add new replacement values
> > > > for any other charatcters you wish to encode when going from Object to XML
> > > >
> > > > i've put it into Flasc for the import/export and it's working great
> > > > so far. Would love to have other's give it a whirl and let me know what
> > > > they think.
> > > >
> > > >
> > > > http://mirror1.cvsdude.com/trac/osflash/xray/browser/downloads/FLASC/XMLObject.as
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > John Grden - Blitz_______________________________________________
> > > osflash mailing list
> > > osflash at osflash.org
> > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > >
> > >
> > > _______________________________________________
> > > osflash mailing list
> > > osflash at osflash.org
> > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > >
> > >
> > >
> > > _______________________________________________
> > > osflash mailing list
> > > osflash at osflash.org
> > > http://osflash.org/mailman/listinfo/osflash_osflash.org
> > >
> > >
> > >
> >
> >
> > --
> > John Grden - Blitz_______________________________________________
> > osflash mailing list
> > osflash at osflash.org
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> >
> > _______________________________________________
> > osflash mailing list
> > osflash at osflash.org
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> >
>
>
> --
> John Grden - Blitz_______________________________________________
> osflash mailing list
> osflash at osflash.org
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
>
>
> _______________________________________________
> osflash mailing list
> osflash at osflash.org
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
>
>
--
John Grden - Blitz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/osflash_osflash.org/attachments/20060314/24c3235c/attachment.htm
More information about the osflash
mailing list