You want to serialize a Collection of objects.
Then , unforunately, you'll have to:
Unserialize the xml to the collection.
Collection.Add(new objectOfYourType);
Serialize and Save.
See some collection xml serialization at:
http://sholliday.spaces.live.com/blog/
9/21/2005
XmlSerialization with IDictionary and CollectionBase Objects
"Frank" <> wrote in message
news:45eca789$0$27061$...
> Hi,
>
> Let's say I have a file named myFile.xml
>
> Within that file I have blocks of data which I'd like to add at different
> times during the day.
>
> e.g.
>
> <LogEntry>
> <Stuff> stuff here </Stuff>
> <LogEntryDate>date time here</LogEntryDate>
> </LogEntry>
> ...
> <LogEntry>
> <Stuff> stuff here </Stuff>
> <LogEntryDate>date time here</LogEntryDate>
> </LogEntry>
>
>
> Now, I'd like to use XMLSerialization, but when appending I get the
<xml...>
> line which I don't want after the first entry.
>
> <?xml version="1.0" encoding="utf-8"?>
>
> Is there a way to use XMLSerializer so that when appending, this line is
not
> added?
>
> Here is my current code, which creates the file if it doesn't exist,
> otherwise appends the next chunk of xml.
>
> XmlSerializer ser = new XmlSerializer(typeof(MyClass));
>
>
> bool bAppend = true;
>
> TextWriter writer = new StreamWriter(strUsageLogFileName, bAppend );
>
> ser.Serialize(writer, this);
>
> writer.Close();
>
>
>
> Thanks for any tips,
>
> Frank
>
>