XNodeAttributes() public method

修改节点元素的属性
public XNodeAttributes ( string>.Dictionary property, System.Xml.Linq.XElement xElement, string xmlPath ) : string
property string>.Dictionary 修改属性的键值对
xElement System.Xml.Linq.XElement 所要修改的节点元素
xmlPath string 保存的xml文件路径
return string
Exemplo n.º 1
0
 /// <summary>
 /// 激活或者关闭项目
 /// </summary>
 /// <param name="nodePath">路径</param>
 /// <param name="name">项目名字</param>
 /// <param name="value">修改后的名字</param>
 /// <returns></returns>
 public string ActiveClose(Dictionary<string,string> project,Dictionary<string,string> property,string nodePath,string xmlConfigPath)
 {
     XmlDao xmlDao = new XmlDao();
     try
     {
         XElement xElement = xmlDao.SelectOneXElement(project, xmlConfigPath, nodePath);
         xmlDao.XNodeAttributes(property, xElement, xmlConfigPath);
         return "successful";
     }
     catch(Exception exception)
     {
         MessageBox.Show(exception.Message);
         return "failed";
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 存储Log(按版本号增加Log节点
 /// </summary>
 /// <param name="value">需要修改的子节点的键值对</param>
 /// <param name="property">需要筛选的属性值的键值对</param>
 /// <param name="xmlPath">xml文件的路径</param>
 /// <param name="nodePath">节点的路径</param>
 /// <returns></returns>
 public string SaveLog(ProjectInfo projectInfo, Dictionary<string, string> property, string xmlPath,
     string nodePath)
 {
     XmlDao xmlDao = new XmlDao();
     var logInfo = new Dictionary<string,string>();
     var logProperty = new Dictionary<string,string>();
     logInfo.Add("Log",projectInfo.Log);
     logProperty.Add("Revision",projectInfo.Revision);
     logProperty.Add("Result",projectInfo.Result);
     logProperty.Add("Time",DateTime.Now.ToString());
     string result = "";
     XElement xElement = xmlDao.SelectOneXElement(property, xmlPath, nodePath);
     xmlDao.AddXNode(logInfo, xElement, xmlPath);
     xElement = xmlDao.SelectOneXElement(property, xmlPath, nodePath);
     result = xmlDao.XNodeAttributes(logProperty, xElement.Elements("Log").Last(), xmlPath);
     return result;
 }