文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>xml解析

xml解析

时间:2011-04-12  来源:uwking

     List<string> xmlstr = new List<string>();
            string path = @"xml文件"; //如D:\软件文档\Player\Project\48001\TaskList.xml
            XmlNodeReader reader = null;
            try
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(path);
                reader = new XmlNodeReader(xd); //创建新的XML reader
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element://判断读到的是否为节点
                            xmlstr.Add(reader.Name);
                            break;
                        case XmlNodeType.Text://判断读到的是否为节点值
                           xmlstr.Add(reader.Value);
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Read XML File Error:" + e.Message + e.StackTrace);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载