更新
This commit is contained in:
74
XmlParser/Teacher.cs
Normal file
74
XmlParser/Teacher.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user