这是 XML:
<PolicyChangeSet schemaVersion="2.1" username="" description="">
<Attachment name="" contentType="">
<Description/>
<Location></Location>
</Attachment>
</PolicyChangeSet>
我只是想在“位置”标签之间添加值“XXX”。
我试过这个,但它不工作:
string newValue = string.Empty;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(AppVars.pxCentralXMLPayloadFilePath);
node = xmlDoc.SelectSingleNode("/PolicyChangeSet/Attachment/location");
node.InnerText = "XXX";
xmlDoc.Save(AppVars.pxCentralXMLPayloadFilePath);
我错过了什么?!