Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?

  #2 (permalink)  
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!

  #3 (permalink)  
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?

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:07 AM.


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