Search code examples
c#.netxmlixmlserializable

XML Serialization, in this case, IXmlSerializable or Attributes


I've done some XML serialization before but i used Attributes, I'm not sure this is doable for my next assignment, here's a brief list of XML manip requirementes.

  • General Purpose XMl manipulation, tied to a treeview, no schema.
  • Load/Save XML.
  • Load/Save Attributes as well as Values (i believe the term is Element Text?), and be mindful of the Node's name.
  • Comments can be safely ignored as can Document info markup (ie, the UTF-8 and schema tags)

Any suggestions on how best to handle this?


Solution

  • I probably wouldn't bother with an object model and IXmlSerializable - it sounds like you might just as well talk in terms of an XmlElement / XmlDocument - i.e. pass the data around as a block of xml. Since you have no schema it would be pointless to shred it out; you might as well do it via an xml DOM.

    When you say treeview - is this winforms, asp.net, wpf? I believe the asp.net treeview can take an xml source, but for winforms you'd have to iterate the nodes yourself.