[英]XML Edit data using XmlDocument in C# <> x </>
I'm using a XmlDocument in C# to edit my Xml file. 我在C#中使用XmlDocument编辑Xml文件。 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();
}
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.