我试图将以下XML响应反序列化为c#对象
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
Error message
</string>
这是我尝试反序列化的对象。不太确定如何使根元素与ErrorMessage
属性匹配
[Serializable]
public class QObject
{
[XmlElement("string")]
public string ErrorMessage { get; set; }
}
当我将QObject
序列化为字符串时,它看起来像这样
<?xml version="1.0" encoding="utf-16"?>
<QObject xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><string>test</string></QObject>