darma teja

darma teja

  • NA
  • 496
  • 336.7k

remove xml node

Jan 31 2018 5:22 AM
My xml file is like this:
 
  1. <root>  
  2. <files>  
  3. <filesource uploadName="20180131T083441_638_Test.doc" originalName="Test.doc">c:\uploadDir\20180131T083441_638_Test.doc</filesource>  
  4. <filesource uploadName="20180131T083441_638_Test1.doc" originalName="Test1.doc">c:\uploadDir\20180131T083441_638_Test1.doc</filesource>  
  5. <filesource uploadName="20180131T083441_638_Test2.doc" originalName="Test2.doc">c:\uploadDir\20180131T083441_638_Test2.doc</filesource>  
  6. </files>  
  7. </root> 
 
in C#:
 
XmlNode filesNodes = xmlFile.findNode("/root/files"); //Here fileNodes has all 3 filessources.


List<string> filenames = new List<string>(); // variable
filesname.add("c:\uploadDir\20180131T083441_638_Test.doc")
filesname.add("c:\uploadDir\20180131T083441_638_Test1.doc")
 
whatever variable-filenames has I want to keep it in xmlfile and rest I want to delete it  from xmlfile.

Answers (1)