Deserialize XML to runtime object

  • Thread starter Thread starter oggelito
  • Start date Start date
O

oggelito

Is this possible?

My goal is to create like an anonymous class, design generated from a
xml file, and populated and lastly displayed to the user.

Is there some fancy .net 3.5/4 solution with like reflection/codedom/
anonymous class that can provide this? I only want the object
temporarily and explore it via reflection.

Option 2 is to use a xmldocument first, then populate a dataset, but
that feels so .net 1.0, pardon my expression.
 
oggelito said:
Is this possible?

My goal is to create like an anonymous class, design generated from a
xml file, and populated and lastly displayed to the user.

It would have to be a class/object first that must be serialized to XML,
because a tag in the XML object identifies that name of the class/object
to be cast back to the class/object.

You can manipulate the object in XML format with an editor to create a
template, but the template must match the properties of the class/object
it was derived from to cast XML back to the object.
Is there some fancy .net 3.5/4 solution with like reflection/codedom/
anonymous class that can provide this? I only want the object
temporarily and explore it via reflection.

I don't know. I don't think so.
Option 2 is to use a xmldocument first, then populate a dataset, but
that feels so .net 1.0, pardon my expression.

Use a dataset and xmldocument for what?

You create a public class/object, the object has public properties, you
populate the object's properties with data, you use the XMLSerializer to
serialize the object to XML or deserialize the XML back to the object.

http://msdn.microsoft.com/en-us/library/aa288470(VS.71).aspx
 
Is this possible?

My goal is to create like an anonymous class, design generated from a
xml file, and populated and lastly displayed to the user.

Is there some fancy .net 3.5/4 solution with like reflection/codedom/
anonymous class that can provide this? I only want the object
temporarily and explore it via reflection.

Option 2 is to use a xmldocument first, then populate a dataset, but
that feels so .net 1.0, pardon my expression.

How would you know the data type of any elements or attributes in the
xml, other than being a string?

Usually, I believe, for this scenario, you would look for an xml schema
(xsd) file.
 
Back
Top