I have a very specific deserialization need, see example below:
say I have following class:
[Serializable]
public class Person {
public string Name { get; set; }
public string PersonXml { get; set; }
}
and following XML
<Person> <Name>John</Name> <PersonXml><someXmlFragment>text</someXmlFragment></PersonXml> </Person>
What I want is the XmlSerializer class to deserialize InnerXml of the <PersonXml> element to the PersonXml property as a string. I'm wondering if it can be done.
NOTE: I know I can encode the content of <PersonXml> escaping illegal XML chars, but I would prefer to leave the inner XML more human friendly (not containing < and other entities that will only cofuse my end user)
The XmlSerializer creates C# (. cs) files and compiles them into . dll files in the directory named by the TEMP environment variable; serialization occurs with those DLLs. These serialization assemblies can be generated in advance and signed by using the SGen.exe tool.
Since XmlSerializer is one of the few thread safe classes in the framework you really only need a single instance of each serializer even in a multithreaded application.
Yes, you can tell the XmlSerializer to ignore namespaces during de-serialization.
XmlSerializer enables you to control how objects are encoded into XML. The XmlSerializer enables you to control how objects are encoded into XML, it has a number of constructors.
You can always implement IXmlSerializable
and do whatever you fancy through XmlReader
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With