Question : deleting some of my xml

Basically say I have the following xml:
<?xml version="1.0" encoding="utf-8" ?>
<Config>
  <Printer></Printer>
  <Report></Report>
  <Misc>
    <CleanUpHTML>1</CleanUpHTML>
    <NextStyleSheet></NextStyleSheet>
    <NonNextStyleSheet></NonNextStyleSheet>
    <ArchivedHTMLFiles>
      <FileName>Order73.html</FileName>
      <FileName>Order77.html</FileName>
    </ArchivedHTMLFiles>
  </Misc>
</Config>

In my code behind I want to read the xml in, loop through the <ArchivedHTMLFiles> and remove the files.

Once I have done this I then want to remove each <File> from the xml and save it again.

What would be the best way to go about this?

My code so far is below.

I just want an answer to deleting the <file> nodes and re-saving.

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
'load our xml config file and pull relevant info into variables
        Dim xmlDoc As New XmlDocument
        xmlDoc.Load(Application.StartupPath & "\DespatchPrintingConfiguration.xml")

        'class variable settings
        _cleanupFiles = xmlDoc.SelectSingleNode("Config/Misc/CleanUpHTML").InnerText

        'get old html files
        For Each hNode As XmlNode In xmlDoc.SelectNodes("Config/ArchivedHTMLFiles")
            'we loop through all the html files that were created and printed
            'during the last print and delete them
            Dim fileName As String = hNode.SelectSingleNode("File").InnerText
            Dim file As New FileInfo(Application.StartupPath & "/" & fileName)

            If file.Exists Then
                file.Delete()
            End If
        Next

        'once we have deleted all the old html files we also need to remove the
        'references to the file in the config xml

Answer : deleting some of my xml

check the code.

the result xml after delete the File tags will be:
<?xml version="1.0" encoding="utf-8"?>
<Config>
 <Printer>
 </Printer>
 <Report>
 </Report>
 <Misc>
   <CleanUpHTML>1</CleanUpHTML>
   <NextStyleSheet>
   </NextStyleSheet>
   <NonNextStyleSheet>
   </NonNextStyleSheet>
   <ArchivedHTMLFiles>
   </ArchivedHTMLFiles>
 </Misc>
</Config>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Dim xmlDoc As New XmlDocument
         xmlDoc.Load(Application.StartupPath & "\DespatchPrintingConfiguration.xml")

  'class variable settings
        _cleanupFiles = xmlDoc.SelectSingleNode("Config/Misc/CleanUpHTML").InnerText


        'get old html files
        For Each hNode As XmlNode In xmlDoc.SelectNodes("Config/Misc/ArchivedHTMLFiles/FileName")

            Dim file As New FileInfo(Application.StartupPath & "/" & hNode.InnerXml)

            If file.Exists Then
                'file.Delete()
            End If
        Next
        For Each hNode As XmlNode In xmlDoc.SelectNodes("Config/Misc/ArchivedHTMLFiles")
            hNode.RemoveAll()
        Next
        xmlDoc.Save("c:\temp\1.xml")
Random Solutions  
 
programming4us programming4us