循环读取XML文件

static void Main(string[] args)
        {
            XmlDocument document = new XmlDocument();
            document.Load("test.xml");//加载你的xml文件,如果为xml字符串,则用document.LoadXml("xmlString");//xmlString为你的字符串变量
  
            XmlNodeList nodeList = document.SelectNodes("rss/channel/item");//从第一级开始读取
  
            foreach (XmlNode item in nodeList)
            {
                string title = item.SelectSingleNode("title").InnerText;//取得title节点
                string description = item.SelectSingleNode("description").InnerText;//取得description节点
  
                Console.WriteLine(string.Concat(title, "------", description));//循环输出所有title和description节点的值
            }
        }


报编码格式错误,用记事本打开,另存为,下面的方法
循环读取XML文件