XmlArray with two unrelated XmlArrayItems

  • Thread starter Thread starter barnum
  • Start date Start date
B

barnum

Hi,

does anyone know if I can have an XmlArray with two unrelated
XmlArrayItem,
i.e. where the items are not child-parent related?

I tried this, but I get an exception when creating the XmlSerializer.
[XmlArray("customers"), XmlArrayItem("names"),
XmlArrayItem("ids")]
(The classes of type "names" and "ids" are not related.)

Thanks for any insight!
 
Hi,

does anyone know if I can have an XmlArray with two unrelated
XmlArrayItem,
i.e. where the items are not child-parent related?

I tried this, but I get an exception when creating the XmlSerializer.
        [XmlArray("customers"), XmlArrayItem("names"),
XmlArrayItem("ids")]
(The classes of type "names" and "ids" are not related.)

Thanks for any insight!

Oooops, the code line above is not correct. But my question is still
valid: "can I have an XmlArray with two unrelated XmlArrayItems, i.e.
where the items are not child-parent related?".
 
You should just be able to declare multiple [XmlArrayItem] entries; what
error are you getting? Alternatively, you can actually do the same thing
with the [XmlElement] that accepts a Type:

[XmlElementAttribute("FOO", typeof(Foo))]
[XmlElementAttribute("BAR", typeof(Bar))]
public List<object> Items
{
get
{
return this.itemsField;
}
}

Marc
 

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

Back
Top