1

My question is very much like this one. However, I need to allow two different namespaces on the same root.

Something like:

    [XmlType(Namespace = "")]
[XmlRoot("included_parameters", Namespace = "http://apif.freescale.net/schemas/paramdef/1.0")]
[XmlRoot("included_parameters", Namespace = "http://apif.freescale.net/schemas/paramdef/1.1")]
public class IncludedParameters
{
}

So basically, I want to deserialize an xml file for version 1.0 of the schema ot 1.1 of the schema into the same .net class.

Please let me know if you need more details.

Chris

2
  • Don't include namespace : [XmlRoot("included_parameters")] Commented May 21, 2015 at 14:57
  • @jdweng - if I remove the Namespace attribute, Deserialize throws an exception saying <included_parameters xmlns='apif.freescale.net/schemas/paramdef/1.0'> was not expected. Commented May 22, 2015 at 16:38

1 Answer 1

0

There is a SerializationBinder class that let one do this kind of type conversion operation.

https://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationbinder%28v=vs.110%29.aspx

"Some users need to control which class to load, either because the class has moved between assemblies or a different version of the class is required on the server and client"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.