如何加载xml到treeview中,并任意修改树结构后再写到xml文件中?
写load部分感觉自己能做点。写save部分就不知道咋写了,希望大家给与帮忙,
/*
* 加载参数
*/
public void LoadPara()
{
XmlDocument myXmlDocument = new XmlDocument();
String sAppIni = Application.StartupPath + "\\ " + Application.ProductName + ".xml ";
try
{
myXmlDocument.Load(sAppIni);
}
catch
{
MessageBox.Show( "请检查文件是否存在: " + sAppIni);
return;
}
XmlNodeList nodeList;
nodeList = myXmlDocument.SelectSingleNode( "chm ").ChildNodes;
//遍历所有子节点
foreach (XmlNode x in nodeList)
{
getchildNode(x);
}
}
public void getchildNode(XmlNode nodelist)
{
XmlNodeList myNodeList;
myNodeList = nodelist.SelectSingleNode( "Node ").ChildNodes;