示例#1
0
文件: Detail.cs 项目: ffblk/epam
 public static Detail FindId(int id)
 {
     string siteDir = HttpContext.Current.Server.MapPath(@"\");
     XmlTextReader reader = new XmlTextReader(siteDir + InputFile);
     Detail p = new Detail();
     int t = 0;
     string t1 = "";
     string t2 = "";
     string t3 = "";
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "id":
                     reader.Read();
                     t = Int32.Parse(reader.Value);
                     break;
                 case "name":
                     reader.Read();
                     t1 = reader.Value;
                     break;
                 case "description":
                     reader.Read();
                     t2 = reader.Value;
                     break;
                 case "link":
                     reader.Read();
                     t3 = reader.Value;
                     break;
             }
             if (t == id)
             {
                 p.Id = t;
                 p.Name = t1;
                 p.Description = t2;
                 p.LinkPic = t3;
             }
         }
     }
     return p;
 }
示例#2
0
文件: Detail.cs 项目: ffblk/epam
 public static List<Detail> Plist()
 {
     string siteDir = HttpContext.Current.Server.MapPath(@"\");
     XmlTextReader reader = new XmlTextReader(siteDir + InputFile);
     List<Detail> pList = new List<Detail>();
     //
     pList.Clear();
     Detail p = null;
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             p = new Detail();
             switch (reader.Name)
             {
                 case "id":
                     reader.Read();
                     p.Id = Int32.Parse(reader.Value);
                     break;
                 case "name":
                     reader.Read();
                     p.Name = reader.Value;
                     break;
                 case "description":
                     reader.Read();
                     p.Description = reader.Value;
                     break;
                 case "link":
                     reader.Read();
                     p.LinkPic = reader.Value;
                     break;
             }
             pList.Add(p);
         }
     }
     return pList;
 }