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?
|