Update value in xml file

前端 未结 4 2098
暖寄归人
暖寄归人 2021-02-14 16:26

I have a xml-file:



  
    
    
    &         


        
4条回答
  •  悲&欢浪女
    2021-02-14 17:04

    //Here is the variable with which you assign a new value to the attribute
        string newValue = string.Empty 
        XmlDocument xmlDoc = new XmlDocument();
    
        xmlDoc.Load(xmlFile);
    
        XmlNode node = xmlDoc.SelectSingleNode("Root/Node/Element");
        node.Attributes[0].Value = newValue;
    
        xmlDoc.Save(xmlFile);
    

    Credit goes to Padrino

    How to change XML Attribute

提交回复
热议问题