Reputation: 1
I'm using a XmlDocument in C# to edit my Xml file. I want to edit data like this:
<Transform>
<Position>x</Position>
</Transform>
But i don't find a matching method yet. I try to solve this and I get something like this:
<Transform>
<Position Positnion=x>x</Position>
</Transform>
Could You give me a method and an easy example how to do this? Thanks ;)
+++ SOLUTION +++
XmlNode formData = xmlDoc.SelectSingleNode("Transform//Position");
if (formData != null)
{
formData.FirstChild.Value = position.ToString();
}
Upvotes: 0
Views: 63
Reputation: 134
I think, help you:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFile);
XmlNode node = xmlDoc.SelectSingleNode("Transform/Position");
node.Attributes[0].Value = newValue;
xmlDoc.Save(xmlFile);
Upvotes: 1