把XML文件修改为这种格式,而不是写到标签的前面。
public void Write(string path,string name,string password)
{
XmlDocument xml = new XmlDocument();
xml.Load(path);
XmlNodeList pXmlNodeList = xml.SelectSingleNode("FileInfo").ChildNodes;
string pathnode = string.Format("/FileInfo");//这里是节点的位置
XmlElement pXmlElement = xml.SelectSingleNode(pathnode) as XmlElement;
pXmlElement.GetElementsByTagName("name").Item(0).InnerText = name;
pXmlElement.GetElementsByTagName("password").Item(0).InnerText = password;
xml.Save(path);
}