My XML is below;
<XML ID="Microsoft Search Thesaurus"> <thesaurus xmlns="x-schema:tsSchema.xml"> <diacritics_sensitive>1</diacritics_sensitive> <expansion> <sub>Internet Explorer</sub> <sub>IE</sub> <sub>IE5</sub> </expansion> <expansion> <sub>run</sub> <sub>jog</sub> </expansion> </thesaurus> </XML>
I want to remove the extension nodes from XML. After deleting the process, it will be like this:
<XML ID="Microsoft Search Thesaurus"> <thesaurus xmlns="x-schema:tsSchema.xml"> </thesaurus> </XML>
My code is below;
XDocument tseng = XDocument.Load("C:\\tseng.xml"); XElement root = tseng.Element("XML").Element("thesaurus"); root.Remove(); tseng.Save("C:\\tseng.xml");
I got the error "The reference to the object is not installed in the instance of the object." for the string "root.Remove ()". How to remove extension nodes from an XML file? Thanks.
source share