XmlArray ??

33 views
Skip to first unread message

Erny

unread,
Aug 17, 2011, 10:47:05 AM8/17/11
to FxWorks
Hi

first of all , great work .. my compliment :)

I try your FlexBX but I have a problem to trasform an xml , this is
an simple example :

<root>
<name>bob</name>
<dad name="mario" city="France">
<child name="bruno" sex="male"/>
<child name="rosa" sex="female"/>
</dad >
</root>

I try width these class:
--------------------------------->
[XmlClass(alias="root" , uri="http://www.lottomatica.it/bingo/
schemas")]
public class Root
{
[XmlElement()]
public var name: String;

[XmlElement()]
public var dad:Dad ;

public function Root()
{

}
}
-------------------------------->
[XmlClass]
public class Dad
{
[XmlAttribute()]
public var name: String ;

[XmlAttribute()]
public var city: String ;

[XmlArray(alias="child" ,type="Child")]
public var Child:Array = new Array () ;

public function Dad()
{

}
}
-------------------------------->

[XmlClass]
public class Child
{
[XmlAttribute()]
public var name: String ;

[XmlAttribute()]
public var sex: String ;

public function Child()
{

}
}
----------------------------------->

bu the result is :

<root>
<name>bob</name>
<dad name="mario" city="France">
<child /> **
<child name="bruno" sex="male"/>
<child name="rosa" sex="female"/>
<child /> **
</dad >
</root>


how can I remove <child /> ** tag ?



thanks


Alexutz

unread,
Aug 17, 2011, 10:59:52 AM8/17/11
to FxWorks
Hello Erny,

Thanks for the compliments, glad you like it.

In the Dad class change this

[XmlArray(alias="child" ,type="Child")]

to

[XmlArray(alias="*", type="Child")]

That should do the trick. The "*" character tells it to not use an
element as wrapper of the children but use the parent xml.

Let me know how it works,
Alex

Alexutz

unread,
Aug 17, 2011, 11:00:54 AM8/17/11
to FxWorks
Sorry,
use this to have the children's names properly set

[XmlArray(alias="*", memberName="child", type="Child")]

Alex
> > thanks- Hide quoted text -
>
> - Show quoted text -

Erny

unread,
Aug 17, 2011, 11:50:39 AM8/17/11
to FxWorks

great !!!!!!!!!!!!!!!!!!!!!!!!!

I spend more and more time to find the soluction , magic trik :)

my application conver xml to object , and I have very very chid
nesteds .....some questions :

1) have I insert [XmlClass] on every class ? (I try without and works
ok);
2) if some xml return without some child or childs , the conversion to
class works correctly too ?


I try to open FlexXB.doc width windows word and openOffice but it
corrupt.

thanks :)

Alexutz

unread,
Aug 17, 2011, 3:03:22 PM8/17/11
to FxWorks
You do not have to insert XmlClass however it is a recommended
practice since it would allow you to better read the xml structure rom
teh metadata itself. It is entirely your choice.

The conversion should go ok in this case too. You will only get a null
value for that field or the exact value computed from the available
xml.

FlexXB.doc works ok for me. Try out this direct link to the SVN
repository: http://code.google.com/p/flexxb/source/browse/trunk/FlexXB/doc/FlexXB.doc

Chers,
Alex
> > > - Show quoted text -- Ascundeţi textul citat -
>
> - Afişare text în citat -

Alexutz

unread,
Aug 17, 2011, 3:04:41 PM8/17/11
to FxWorks
Or better yet this one which is the actual direct link :D
http://flexxb.googlecode.com/svn/trunk/FlexXB/doc/FlexXB.doc

On 17 aug., 22:03, Alexutz <alex.id.ciob...@gmail.com> wrote:
> You do not have to insert XmlClass however it is a recommended
> practice since it would allow you to better read the xml structure rom
> teh metadata itself. It is entirely your choice.
>
> The conversion should go ok in this case too. You will only get a null
> value for that field or the exact value computed from the available
> xml.
>
> FlexXB.doc works ok for me. Try out this direct link to the SVN
> repository:http://code.google.com/p/flexxb/source/browse/trunk/FlexXB/doc/FlexXB...
> > - Afişare text în citat -- Ascundeţi textul citat -

Erny

unread,
Aug 18, 2011, 3:28:17 AM8/18/11
to FxWorks
works :)

thanks

On 17 Ago, 21:04, Alexutz <alex.id.ciob...@gmail.com> wrote:
> Or better yet this one which is the actual direct link  :Dhttp://flexxb.googlecode.com/svn/trunk/FlexXB/doc/FlexXB.doc
> > > > > - Show quoted text -- Ascundeþi textul citat -
>
> > > - Afiºare text în citat -- Ascundeþi textul citat -
>
> > - Afiºare text în citat -

Erny

unread,
Aug 18, 2011, 3:28:31 AM8/18/11
to FxWorks
thanks

On 17 Ago, 21:03, Alexutz <alex.id.ciob...@gmail.com> wrote:
> You do not have to insert XmlClass however it is a recommended
> practice since it would allow you to better read the xml structure rom
> teh metadata itself. It is entirely your choice.
>
> The conversion should go ok in this case too. You will only get a null
> value for that field or the exact value computed from the available
> xml.
>
> FlexXB.doc works ok for me. Try out this direct link to the SVN
> repository:http://code.google.com/p/flexxb/source/browse/trunk/FlexXB/doc/FlexXB...
> > > > - Show quoted text -- Ascundeþi textul citat -
Reply all
Reply to author
Forward
0 new messages