C# winform 查找指定節點值
簡單粗暴,直接上代碼:
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-----想要查找的節點