XML attribute for serialization

A

Albert Jan

Hi,

I use XML in a webservice that looks like this:

<address>
<addressline>aaaa</addressline>
<addressline>aaaa</addressline>
<zip></zip>
<city></city>
</address>

which I want to serilize to objects.

When <address> does only contain <addressline> tags, I can use an attribute
like

[XmlArrayItem (typeof(addresslineType), ElementName = "addressline")]
virtual public addresslineType[] Address
{
get {return address;}
set{this.address= value;}
}
private addresslineType[] address;


for the adress object.

But because <address> also contains other elements I don't know what
attribute to use for correct serialization

Any help will be appreciated

Albert Jan
 
D

Drew Robbins

You can use the XmlElement attribute...

[XmlElement("addressline")]
public addressAddressline[] Address
{ get; set; }
 
A

Albert Jan

Some things can be so easy ;-)

Thanks!

Albert Jan

Drew Robbins said:
You can use the XmlElement attribute...

[XmlElement("addressline")]
public addressAddressline[] Address
{ get; set; }

Albert said:
Hi,

I use XML in a webservice that looks like this:

<address>
<addressline>aaaa</addressline>
<addressline>aaaa</addressline>
<zip></zip>
<city></city>
</address>

which I want to serilize to objects.

When <address> does only contain <addressline> tags, I can use an attribute
like

[XmlArrayItem (typeof(addresslineType), ElementName = "addressline")]
virtual public addresslineType[] Address
{
get {return address;}
set{this.address= value;}
}
private addresslineType[] address;


for the adress object.

But because <address> also contains other elements I don't know what
attribute to use for correct serialization

Any help will be appreciated

Albert Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top