If there is a simple one to one mapping from your business objects to the
XML format you want then the XmlSerializer is the easiest way. If the
mapping is more complicated you may have to use other classes in the
System.Xml namespace as follows:
1) The XmlSerializer uses the XmlTextReader for reading and the
XmlTextWriter for writing. You could write directly to these classes also
which give you the best performance. The only down side here is you may end
up writing a lot of code, WriteStartElement, WriteAttribute,
WriteEndElement, and so on.
2) Alternately, you could serialize your business objects into an
XmlDocument, then use XslTransform to transform this into the desired XML
format. Another XslTransform can be written to do the reverse transform.
Another approach to the output side of this equation is to bypass
XmlDocument by using the ObjectXPathNavigator, that you can find on MSDN, to
pump your business objects directly through an XslTransform and produce your
output that way. But ObjectXPathNavigator is just a sample code, you would
have to be comfortable with owning/improving that code as needed.
3) Another clever approach is to make your business objects a "wrapper" on
top of XmlNode, so the data is actually stored in an XmlNode (XmlElement,
XmlAttribute, XmlText, etc), but your app gets a strongly typed programming
model via your wrapper classes. This is a "databinding" approach. Here the
"binding" process walks the XmlDocument that you loaded, and populates
collections of your "bound" business objects. The XmlDataDocument is an
example of this concept, where in this case the "bound" objects are
DataTables and DataRows in a DataSet.
"herbert" <an*******@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
I need to use XML file as a replacement for a script file. The XML file is
is created by a (graphical) editor and the XML file then drives a runtime
engine as in WorkFlow or VoiceMail systems.
Beeing new to XML, how do I best
a) create the XML file from .net business objects in the editor?
b) parse and interprete the XML file in the runtime system?
Or is it better to stay with a serialized object model as the intermediate
file format?
VB.NET examples preferred.
thanks, herbert