p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=138)
-   -   document.DocumentElement.RemoveChild Error (http://p2p.wrox.com/showthread.php?t=45133)

jrbancroft July 12th, 2006 10:30 AM

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?


jrbancroft July 13th, 2006 01:27 AM

Problem Solved :D!


tfmalone August 7th, 2006 10:36 PM

Having the same problem with the XML example in Microsoft's "101 Examples". What was your solution?



All times are GMT -4. The time now is 02:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.