日期:2014-05-17 浏览次数:20971 次
XmlDocument xml = new XmlDocument(); xml.Load("XML路径"); Console.WriteLine(xml.DocumentElement.Name);
------解决方案--------------------
using (Stream st = File.OpenRead("xml文件路径"))
{
using (StreamReader sr = new StreamReader(st, Encoding.UTF8))
{
XDocument xdoc = XDocument.Load(sr);
//获得根节点XElement
XElement xe = xdoc.Root;
}
}
XDocument是.NET 4.0
------解决方案--------------------
path = @"./xxxxx.xml"; if (File.Exists(kinfopath)) { XElement xmldoc = XElement.Load(path); string str = xmldoc.Name.ToString(); }
------解决方案--------------------
path = @"./xxxxx.xml"; if (File.Exists(path)) { XElement xmldoc = XElement.Load(path); string str = xmldoc.Name.ToString(); }