オブジェクトにシリアル化しようとしているXMLファイルがあります。一部の要素は無視されています。
私のXMLファイル:
<?xml version="1.0" encoding="utf-8" ?>
<License xmlns="http://schemas.datacontract.org/2004/07/MyApp.Domain">
<Guid>7FF07F74-CD5F-4369-8FC7-9BF50274A8E8</Guid>
<Url>http://www.gmail.com</Url>
<ValidKey>true</ValidKey>
<CurrentDate>3/1/2010 9:39:28 PM</CurrentDate>
<RegistrationDate>3/8/2010 9:39:28 PM</RegistrationDate>
<ExpirationDate>3/8/2099 9:39:28 PM</ExpirationDate>
</License>
私のクラス定義:
[DataContract]
public class License
{
[DataMember]
public virtual int Id { get; set; }
[DataMember]
public virtual string Guid { get; set; }
[DataMember]
public virtual string ValidKey { get; set; }
[DataMember]
public virtual string Url { get; set; }
[DataMember]
public virtual string CurrentDate { get; set; }
[DataMember]
public virtual string RegistrationDate { get; set; }
[DataMember]
public virtual string ExpirationDate { get; set; }
}
そして私のシリアル化の試み:
XmlDocument Xmldoc = new XmlDocument();
Xmldoc.Load(string.Format(url));
string xml = Xmldoc.InnerXml;
var serializer = new DataContractSerializer(typeof(License));
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
License license = (License)serializer.ReadObject(memoryStream);
memoryStream.Close();
次の要素がシリアル化されます。
- GUID
- ValidKey
次の要素はシリアル化されていません。
- URL
- 現在の日付
- 登録日
- 有効期限
xmlファイルの文字列の日付を「blah」に置き換えても機能しません。何が得られますか?