View Single Post
  #1 (permalink)  
Old July 12th, 2006, 10:30 AM
jrbancroft jrbancroft is offline
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default document.DocumentElement.RemoveChild Error

Hi

I keep getting the error: Object reference not set to an instance of an object when I run this code:

private static void RemoveRemainingNode(string filename)
        {
            XmlDocument document = new XmlDocument();

            document.Load(filename);

            XmlNode node = document.SelectSingleNode("Host");
            document.DocumentElement.RemoveChild(node);
            document.Save(filename);
        }

<?xml version="1.0"?>
<FailedHosts>
<Host>domain.com</Host>
</FailedHosts>

All I am trying to to is remove the line <Host>domain.com</Host>.

Any Ideas?