• C#解析XML


    <checkResult>
    <item>
    <fmId>XX0001</fmId>
    <fmItemId>20000RT</fmItemId>
    <checkRuleId>4C6A0458-29B4-4CE6-B38C-38CDEE3CD3C2</checkRuleId>
    <isAcct>不影响</isAcct>
    <soluation>不需要方案,因为不涉及</soluation>
    <evaluate>注意,这是一条评论</evaluate>
    </item>
    <item>
    <fmId>XX0002</fmId>
    <fmItemId>20000RT</fmItemId>
    <checkRuleId>A4C12D83-DC18-427D-839F-7DB68EF730BF</checkRuleId>
    <isAcct>影响</isAcct>
    <soluation>方案还在拟定当中,请注意节奏</soluation>
    <evaluate>It is a evaluate</evaluate>
    </item>
    </checkResult>

    public class DizCheckResult
    {
    public string fmId { get; set; }
    public string fmItemId { get; set; }
    public string checkRuleId { get; set; }
    public string isAcct { get; set; }
    public string soluation { get; set; }
    public string evaluate { get; set; }
    }

    public static List<DizCheckResult> GetCheckResultList()
            {
                List<DizCheckResult> tmpList = new List<DizCheckResult>();
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(@"f:myprojectx.xml");
                //XmlNodeList nodelist = xmlDoc.GetElementsByTagName("checkResult/item");
                XmlNodeList nodelist = xmlDoc.SelectNodes("checkResult/item");
                foreach(XmlNode node in nodelist)
                {
                    DizCheckResult entity = new DizCheckResult();
                    entity.fmId = HttpUtility.HtmlEncode(node["fmId"].InnerText);
                    entity.fmItemId = HttpUtility.HtmlEncode(node["fmItemId"].InnerText);
                    entity.checkRuleId = node["checkRuleId"].InnerText;
                    entity.isAcct = node["isAcct"].InnerText;
                    entity.soluation = node["soluation"].InnerText;
                    entity.evaluate = node["evaluate"].InnerText;
                    tmpList.Add(entity);
                }
                return tmpList;
            }
  • 相关阅读:
    B+树的Copy-on-Write设计
    so库链接和运行时选择哪个路径下的库?
    Xapian索引-文档检索过程分析之匹配百分比
    Xapian索引-文档检索过程分析
    Xapian的内存索引-添加文档
    Xapian的内存索引
    Xapian使用入门
    一个std::sort 自定义比较排序函数 crash的分析过程
    编译GCC4.8.2
    使用C++11的一点总结
  • 原文地址:https://www.cnblogs.com/zoujinhua/p/15098009.html
Copyright © 2020-2023  润新知