//Look for node MyNode
XmlNode node = doc.SelectSingleNode("//MyNode");
//Create empty attribute
XmlAttribute attribute = doc.CreateAttribute("MyAttrib2");
//Remove any existing attribute with that name just in case
node.Attributes.Remove(attribute);
//Set the value of the attribute
attribute.Value = "1";
//Add the attribute to the node
XmlAttribute attributeBefore = node.Attributes["MyAttrib1"];
node.Attributes.InsertAfter(attribute, attributeBefore);
No comments:
Post a Comment