Deserialize dynamic/variable Inner XML
I have an XML configuration file:
<Config>
<FixedElement1/>
<FixedElement2/>
<UserDefine开发者_StackOverflowdElement>
<UnknownUserElement1/>
<UnknownUserElement2/>
</UserDefinedElement>
</Config>
I have serialization and deserialization working on the fixed elements. But I want to read user defined elements that are not known.
How can I do it?
I am trying to do this way but it returns me nothing [XmlText] public String UserDefinedElement{ get; set; }
Thanks for the answer.
You can achieve this in the app.config by defining custom config sections which can be deserialised into an object collection. A good guide on achieving this can be found here: http://devlicio.us/blogs/derik_whittaker/archive/2006/11/13/app-config-and-custom-configuration-sections.aspx
If you are wishing to use your custom config you will still need to specify the object which has been serialized. If you are implementing ISerializable then you can use reflection to determine the object type and create at run-time.
精彩评论