Serializing an Array Collection containing primitive data types

12 views
Skip to first unread message

Ranhiru

unread,
Jun 20, 2011, 4:30:42 AM6/20/11
to FxWorks
In one of my classes I have an ArrayCollection which contains
integers.

[XmlArray]
public var actionIds:ArrayCollection = new ArrayCollection();

Now this serializes to something like this. Looks like its separated
by an enter

<actionIds>
1 2
</actionIds>

Then I made the annotation to

XmlArray(alias="actionIds/id")]
public var actionIds:ArrayCollection = new ArrayCollection();

But my expected result was not achieved. The result was as shown
below.

<actionIds>
<id> 1 2 </id>
</actionIds>

However, what I am trying to achieve is to wrap each element in a <id>
tag. So it would result in

<actionIds>
<id>1</id>
<id>2</id>
</actionIds>

Any ideas? Looks like this could be solved using virtual paths.

Thanx a lot in advance!

Alexutz

unread,
Jun 20, 2011, 5:03:25 AM6/20/11
to FxWorks
Did you try setting memberName="id" in the xmlArray metadata and
leaving alias to just "actions"? That should lead to the expected
result.

Alex

Ranhiru

unread,
Jun 20, 2011, 5:54:25 AM6/20/11
to FxWorks
Thanx a lot! That worked perfectly!

Alexutz

unread,
Jun 20, 2011, 7:08:50 AM6/20/11
to FxWorks
No problem. I'm glad it worked.

Good luck
> > > Thanx a lot in advance!- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages