私はこのXML要素文字列を持っています:
<person name="jhon smith" birth="11/10/1988" username="ilearn" password="123"/>
ここで、これをそれぞれのオブジェクトに逆シリアル化します。
public class CancelCardResponse
{
public string name { get; set; }
public string birth { get; set; }
public string username { get; set; }
public string password { get; set; }
}
私はこれに似たコードを使用しています:
XmlSerializer deserializer = new XmlSerializer(typeof(Person));
StringReader reader = new StringReader(myxmlelementstring);
var a = deserializer.Deserialize(reader); // fail!
エラーは次のようになります。
System.InvalidOperationException {" XMLドキュメント(1,2)にエラーがあります。 "}
上記のようなXML要素文字列を逆シリアル化することは可能ですか?
C#デシリアライザーを使用するためにXML要素文字列に追加できるものはありますか?