Files
06-Note/XmlParser/Teacher.cs
sherlockforrest bf2ed2e31f 更新
2023-06-20 09:22:53 +08:00

74 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
namespace XmlParserByAttribute
{
[XmlRoot("teacher")]
public class Teacher
{
[XmlAttribute("LessonTitle")]
public string LessonTitle { get; set; }
[XmlElement("general")]
public general general { get; set; }
[XmlElement("descrption")]
public descrption descrption { get; set; }
[XmlElement("part")]
public List<part> partlist { get; set; }
}
public class general
{
[XmlAttribute("title")]//是string类型
public string title { get; set; }
[XmlAttribute("msg")]
public string msg { get; set; }
}
public class descrption
{
[XmlAttribute("document")]
public string document { get; set; }
}
public class part
{
[XmlAttribute("PartTitle")]
public string PartTitle { get; set; }
[XmlAttribute("PartNum")]
public string PartNum { get; set; }
[XmlAttribute("PartOver")]
public string PartOver { get; set; }
[XmlElement(ElementName = "sco", Type = typeof(sco), IsNullable = true)]
[XmlElement(ElementName = "quest", Type = typeof(quest), IsNullable = true)]
public List<kk> kks { get; set; }
}
//part内有两个节点为了合并到一个合集里声明父类kk用以合并两个子类到一个合集里
public class kk
{
}
public class quest : kk
{
[XmlAttribute("Title")]
public string Title { get; set; }
}
public class sco : kk
{
[XmlAttribute("ScoTitle")]
public string ScoTitle { get; set; }
[XmlAttribute("isok")]
public string isok { get; set; }
}
}