Re: Is using XmlSerializer the right choice?



Hi,

You can decide if you would use the XmlSerializer or not based on how you
want to design your classes; because XmlSerializer imposes certain
restrictions on your classes desings. Mainly, you must have a default
constructor and you must have getters and setters on all properties that you
want to serialize, if that is the way you are building your class, then use
the XmlSerializer, otherwise if you feel unhappy with these restrictions,
then you can go your own way.


<yinjennytam@xxxxxxxxxxxxxxxx> wrote in message
news:4E8CF731-F36F-4B61-B323-0DA8B3994476@xxxxxxxxxxxxxxxx
> Hi all
>
> I'm learning XML and .NET and I saw an example of using XmlSerializer to
> deserialize an XML file to get the corresponding object in memory. I
> found
> it very useful for my purpose. However, for simple properties it works
> for
> me, but I actually need a bit more than just properties.
>
> For example, my class actually contains a collection of strings as well,
> now
> is using XmlSerializer the right choice? I don't know how many there will
> be, but ideally I can just create a file (say an XML) and add as many
> strings
> as necessary such that they will be added to the collection of the object
> in
> memory.
>
> Any pointers or suggestions are greatly appreciated! Thanks!
>


.



Relevant Pages

  • Re: XmlSerialization base classes
    ... to strip out the other XML attributes from your class definitions. ... Junk and DerivedJunk to test this further. ... > unfortunate because now using the XmlSerializer as a middle tier for data ... >> Kevin Spencer ...
    (microsoft.public.dotnet.framework.aspnet)
  • XmlSerializer, C# , Excel, XML and SpreadsheetML
    ... formatting. ... using XmlSerializer. ... public Cell Cells; ... Example code of Xml Serialization should include the resulting Xml in the ...
    (microsoft.public.dotnet.framework)
  • Re: Regarding performance on objects serialized to Xml - thoughts and code presented
    ... > not use XmlSerializer or the SoapFormatter? ... > instance and add the XML to that. ... would accept the performance penaulty if that ment that I didn't have to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: HOWTO Overcome missing namespace declaration in root node
    ... you're trying to deserialize two entirely different XML formats. ... An XmlSerializer is really only good at processing one format. ... XmlSerializer ser2 = new XmlSerializer(typeof(TransferManifest), ... >> you posted would not deserialize because it's missing the XML namespace ...
    (microsoft.public.dotnet.xml)
  • Re: XmlSerializer, C# , Excel, XML and SpreadsheetML
    ... To get the arrays to emit the correct xml tags you can add the ... To force the namespace prefix on the attribute add the ... XmlSerializer xs = new XmlSerializer); ... public Cell[] Cells; ...
    (microsoft.public.dotnet.framework)

Loading