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 / ASP.NET / Web Services / August 2005

Tip: Looking for answers? Try searching our database.

xml attributes and serialization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Giles M - 05 Aug 2005 14:47 GMT
i need to serialize my class into xml that looks like this:

<dog>
    <breed type="large">spaniel</breed>
</dog>

but i'm not sure how to get an attribute into a property of my class, i can
use the xmlattribute tag to make an attribute of my dog class but i want an
attribute on my property, is this possible? if so how do i do it?

many thanks

Giles Morris
Marvin Smit - 05 Aug 2005 16:41 GMT
Hi,

you should be able to do this. I've just tested this class and it
produces the output you where giving as an example. (with an
additional namespace)

[XmlRootAttribute(Namespace="http://www.marv-in.net/Examples/XMLandSuch",
sNullable=false)]
public class Dog
{
    /// <remarks/>
    public DogBreed breed;
}
/// <remarks/>
public class DogBreed
{
    /// <remarks/>
    [XmlTextAttribute]
    public string Text;
    /// <remarks/>
    [XmlAttributeAttribute]
    public string type;
}

Hope this helps,

Marvin Smit.

>i need to serialize my class into xml that looks like this:
>
[quoted text clipped - 9 lines]
>
>Giles Morris

Rate this thread:







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.