Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2006, 10:30 AM
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?

 
Old July 13th, 2006, 01:27 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem Solved :D!

 
Old August 7th, 2006, 10:36 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Err,This document already has DocumentElement node ismailc XSLT 5 December 24th, 2007 12:40 PM
removeChild help John123 RSS and Atom 1 November 19th, 2007 12:56 PM
multiple documentElement (html) objects in one doc hussainm HTML Code Clinic 2 July 14th, 2006 02:40 PM
javascript: window.open & document.documentElement rockon Javascript 2 February 3rd, 2005 04:36 PM
Need help with documentElement.removeChild adsioii XSLT 2 January 16th, 2004 02:12 PM





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