Im trying to deserialize the response from this simple web service
Im using the following code:
WebRequest request = WebRequest.Create(\"http://inb37
I had the same error with Deserialize "xml string with 2 namespaces declared" into object.
Can't get PAN
[XmlRoot(ElementName = "errorNotification", Namespace = "http://def")]
public class ErrorNotification
{
[XmlAttribute(AttributeName = "vcs-pos", Namespace = "http://www.w3.org/2000/xmlns/")]
public string VcsPosNamespace { get; set; }
[XmlAttribute(AttributeName = "vcs-device", Namespace = "http://www.w3.org/2000/xmlns/")]
public string VcsDeviceNamespace { get; set; }
[XmlElement(ElementName = "errorText", Namespace = "")]
public string ErrorText { get; set; }
}
By adding field with [XmlAttribute] into ErrorNotification class deserialization works.
public static T Deserialize(string xml)
{
var serializer = new XmlSerializer(typeof(T));
using (TextReader reader = new StringReader(xml))
{
return (T)serializer.Deserialize(reader);
}
}
var obj = Deserialize(xml);