1、一个XML对应一个对象,对象序列化之后变成xml

public class student

{

   public Student()
    {//空构造函数
    } 

 public Student(string name, int age)//有参数的构造函数
    {
        this.name = name;
        this.age = age;
    }

[System.Xml.Serialization.XmlElement("studentname")]//指出在把对象序列化为XML时,Name属性序列化为XML的“元素”,而不是“属性”

     public string Name//属性
    {
        get { return this.name; }
        set { this.name = value; }
    }

[System.Xml.Serialization.XmlAttribute("studentage")]//指出在把对象序列化为XML时,Age属性序列化为XML的“属性”,而不是“元素”

public int Age
    {
        get { return this.age; }
        set { this.age = value; }
    } 

}

2.有xml生成对应的xsd

xsd.exe xml文件  /out xsd的存放路径

3、由xsd价格生成对应的dataset 或者class

xsd.exe F:\XML\student.xsd /classes /language:cs /out:F:\XML  (可缩写:/c  /d  /o)
xsd.exe F:\XML\student.xsd /dataset /language:cs /out:F:\XML

 


 

相关文章:

  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-01-14
  • 2021-08-30
  • 2021-11-01
  • 2022-12-23
  • 2021-06-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-11-05
  • 2021-08-25
  • 2021-11-15
相关资源
相似解决方案