나는 다음과 같은 정의 된 클래스, 직렬화하려고 :클래스는 클래스 이름없이 XML로 직렬화
[DataContract]
public class Human
{
public Human() { }
public Human(int id, string Name, bool isEducated)
{
this.id = id;
this.Name = Name;
this.isEducated = isEducated;
}
[DataMember]
public int id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public bool isEducated { get; set; }
}
그 다음이 연재되고있는 것
:
Human h = new Human(id, Name, isEducated);
XmlRootAttribute root = new XmlRootAttribute();
root.ElementName = "Repository";
XmlSerializer xs = new XmlSerializer(typeof(Human), root);
FileStream fs = new FileStream(fname, FileMode.Open);
xs.Serialize(fs, h);
을 그리고 이것은 결과입니다 :
<Repository xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<id>1</id>
<Name>Vill</Name>
<isEducated>false</isEducated>
</Repository>
내가 원하는 것은 아닙니다. 클래스 이름은 그냥 생략됩니다. 여기에 어떤 문제가 있습니까?
는 "루트"물건없이 그것을 시도 나는 아래에 당신을 위해 일 수있는 무언가의 예를 가지고있다. –