Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2008

Tip: Looking for answers? Try searching our database.

XmlArray with two unrelated XmlArrayItems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
barnum@bluezone.no - 30 May 2008 13:06 GMT
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!
barnum@bluezone.no - 30 May 2008 13:19 GMT
On 30 Mai, 14:06, bar...@bluezone.no wrote:
> Hi,
>
[quoted text clipped - 8 lines]
>
> 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?".
Marc Gravell - 30 May 2008 14:26 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.