該代碼不起作用。它不會刪除path4節點,我該怎麼做?請幫幫我。謝謝。我想從xml用戶選擇路徑的文件中移除xml節點?
<WindowEntries>
<WindowEntry>
<Name>tbwUnitOverview</Name>
<View>TRN_UNIT</View>
<LU>TrnUnit</LU>
<DefaultWindowText> windowtext</DefaultWindowText>
<Flags>0</Flags>
</WindowEntry>
<WindowEntry>
<Name>tbwBrandOverView</Name>
<View>TRN_BRAND</View>
<LU>TrnBrand</LU>
<DefaultWindowText />
<Flags>0</Flags>
</WindowEntry>
<WindowEntry>
<Name>tbwProductCategory</Name>
<View>TRN_PROD_CATEGORY</View>
<LU>TrnProdCategory</LU>
<DefaultWindowText />
<Flags>0</Flags>
</WindowEntry>
XmlTextReader reader = new XmlTextReader("component.xml");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNode currNode;
string path4 = treeView1.SelectedNode.FullPath.ToString();
currNode = doc.SelectSingleNode(path4);
currNode.RemoveAll();
doc.Save("component.xml");
該代碼不起作用。它不會刪除path4節點,我該怎麼做,請幫助我。謝謝。 – maduranga
可能的重複http://stackoverflow.com/questions/7074621/how-do-i-replace-a-xml-node/7074676#7074676 – Zenwalker
你第一次理解你寫的代碼嗎?你有調試過嗎? – Zenwalker