Subject: document.DocumentElement.RemoveChild Error
Posted By: jrbancroft Post Date: 7/12/2006 10:30:45 AM
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?

Reply By: jrbancroft Reply Date: 7/13/2006 1:27:23 AM
Problem Solved !

Reply By: tfmalone Reply Date: 8/7/2006 10:36:27 PM
Having the same problem with the XML example in Microsoft's "101 Examples". What was your solution?


Go to topic 45388

Return to index page 209
Return to index page 208
Return to index page 207
Return to index page 206
Return to index page 205
Return to index page 204
Return to index page 203
Return to index page 202
Return to index page 201
Return to index page 200