tags:

views:

13

answers:

1

Hi, using xds.exe i created following class:

namespace vgtunesWPF
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class Library
{

    private LibraryTrack[] mediaField;

    private string playListsField;

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayItemAttribute("Track", IsNullable = false)]
    public LibraryTrack[] Media
    {
        get
        {
            return this.mediaField;
        }
        set
        {
            this.mediaField = value;
        }
    }

    /// <remarks/>
    public string PlayLists
    {
        get
        {
            return this.playListsField;
        }
        set
        {
            this.playListsField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class LibraryTrack
{

    private string idField;

    private string locationField;

    private string titleField;

    private string artistField;

    private string albumField;

    private string jaarField;

    private string genreField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(DataType = "ID")]
    public string ID
    {
        get
        {
            return this.idField;
        }
        set
        {
            this.idField = value;
        }
    }

    /// <remarks/>
    public string Location
    {
        get
        {
            return this.locationField;
        }
        set
        {
            this.locationField = value;
        }
    }

    /// <remarks/>
    public string Title
    {
        get
        {
            return this.titleField;
        }
        set
        {
            this.titleField = value;
        }
    }

    /// <remarks/>
    public string Artist
    {
        get
        {
            return this.artistField;
        }
        set
        {
            this.artistField = value;
        }
    }

    /// <remarks/>
    public string Album
    {
        get
        {
            return this.albumField;
        }
        set
        {
            this.albumField = value;
        }
    }

    /// <remarks/>
    public string Jaar
    {
        get
        {
            return this.jaarField;
        }
        set
        {
            this.jaarField = value;
        }
    }

    /// <remarks/>
    public string Genre
    {
        get
        {
            return this.genreField;
        }
        set
        {
            this.genreField = value;
        }
    }
}
}

it is used to create following XML:

<Library>
 <Media>
    <Track>
      <ID>0</ID>
      <Location>url</Location>
      <Title>title</Title>
      <Artist>artist</Artist>
      <Album>album</Album>
      <Jaar>year</Jaar>
      <Genre>genre</Genre>
    </Track>
      <ID>1</ID>
      <Location>url</Location>
      <Title>title</Title>
      <Artist>artist</Artist>
      <Album>album</Album>
      <Jaar>year</Jaar>
      <Genre>genre</Genre>
    </Track>
 </Media>
</Library>

the problem here is thus that i don't have a clue how to fill the xml while keeping the data stored in it.

+1  A: 

It sounds like you want to merge your existing XML data with new data stored in the class.

The best way to do that would be to deserialize the xml to an instance of that class, make your changes and then serialize it again.

Justin Dearing
OK thx it was a fairly simple answers :D really need to think out of the box here.
Maarten Van Genechten