您的位置:首页 > 编程语言 > C#

C# winform 查找指定节点值

2015-04-02 17:34 204 查看
简单粗暴,直接上代码:

XmlDocument xmlDoc = new XmlDocument();

try

{

xmlDoc.Load(Help.basePath);

XmlNode root = xmlDoc.SelectSingleNode("//screenshot");

if (root != null)

{

string screenshotsavepath = root.SelectSingleNode("screenshotsavepath").InnerText;

//打开文件夹



}

else

{

MessageBox.Show("亲,没有有效存储路径");

}

}

catch (Exception ex)

{

//显示错误信息

MessageBox.Show(ex.Message);

}

Help.basePath-------------------文件路径

screenshot--------------------节点名

screenshotsavepath-----想要查找的节点
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: