xml attribute serialization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Giles M

    #1

    xml attribute serialization

    i need to serialize my class into xml that looks like this:

    <dog>
    <breed type="large">sp aniel</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
  • Axel Dahmen

    #2
    Re: xml attribute serialization

    How about something like:

    class Breed
    {
    [XmlText]
    string Name;

    [XmlAttribute]
    string type;
    }

    class Dog
    {
    Breed breed;
    }

    Type, like the breed's name is a property on its own. Both are kind of
    attributes on breed. Only complex types (classes) can have more than one
    property.

    HTH,

    Axel Dahmen

    --------------------
    "Giles M" <GilesM@discuss ions.microsoft. com> schrieb im Newsbeitrag
    news:787EF12D-6AB5-4668-8941-9A28AE30C07C@mi crosoft.com...[color=blue]
    > i need to serialize my class into xml that looks like this:
    >
    > <dog>
    > <breed type="large">sp aniel</breed>
    > </dog>
    >
    > but i'm not sure how to get an attribute into a property of my class, i[/color]
    can[color=blue]
    > use the xmlattribute tag to make an attribute of my dog class but i want[/color]
    an[color=blue]
    > attribute on my property, is this possible? if so how do i do it?
    >
    > many thanks
    >
    > Giles Morris[/color]


    Comment

    Working...