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

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top