当前位置:首页 >.NET > 正文内容

C#DOM读XML文件

大滑稽11年前 (2014-03-24).NET1131

public void LoadXML()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("ArticleConfig.xml");

            XmlNode rootNode = doc.DocumentElement;

            foreach (XmlNode subNode in rootNode.ChildNodes)
            {
                switch (subNode.Name)
                {
                    case "startID":
                        art.StartID = Convert.ToInt32(subNode.InnerText);
                        break;
                    case "endID":
                        art.EndID = Convert.ToInt32(subNode.InnerText);
                        break;
                    case "currentID":
                        art.CurrentID = Convert.ToInt32(subNode.InnerText);
                        break;
                    case "step":
                        art.Step = Convert.ToInt32(subNode.InnerText);
                        break;
                    case "url":
                        art.Url = subNode.InnerText;
                        break;
                    case "type":
                        art.ArticleType = subNode.InnerText;
                        break;
                    case "savePath":
                        hdl.SavePath = subNode.InnerText;
                        break;
                    case "titleTag":
                        hdl.TitleTagName = subNode.InnerText;
                        break;
                    case "titleClass":
                        hdl.TitleClassName = subNode.InnerText;
                        break;
                    case "titleID":
                        hdl.TitleID = subNode.InnerText;
                        break;
                    case "txtTag":
                        hdl.TxtTagName = subNode.InnerText;
                        break;
                    case "txtClass":
                        hdl.TxtClassName = subNode.InnerText;
                        break;
                    case "txtID":
                        hdl.TxtID = subNode.InnerText;
                        break;
                    case "replace":
                        hdl.Replace = subNode.InnerText.Split(',');
                        break;
                }
            }
        }
 


扫描二维码推送至手机访问。

版权声明:本文由第★一★次发布,如需转载请注明出处。

本文链接:https://wpers.net/post/36.html

标签:C#.NETXML

“C#DOM读XML文件” 的相关文章

Cbo控件数据源绑定

 //Cbo控件数据源绑定DataTable DtType = noteType.GetTypeList("");         ...

C#遍历控件的方法

首先,要想遍历,就必须找到你想找的表单里面的所有控件,然后一个个的逐一比对,当找到了你需要的控件的时候,再做你需要的操作。1、foreach方法foreach (Control control in ...

Linq读写XML

         private List<News> GetNews(string html)    &n...

c#中分页显示数据

     //c#中分页显示数据    public partial class Form1 : Form    {  ...

C#获得程序集

 //获得程序集System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();...

以ToolStrip为例绘制简便背景

//以ToolStrip为例绘制简便背景e.Graphics.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(...