Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7526543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:51:34+00:00 2026-05-30T03:51:34+00:00

I load an XmlDocument and then select some nodes into an XmlNodeList instance. If

  • 0

I load an XmlDocument and then select some nodes into an XmlNodeList instance. If I edit any of those nodes, the XmlDocument will be modified

XmlDocument xd = loadXml();
XmlNodeList xnl = xd.SelectNodes("/root/nodes");

foreach (XmlNode n in xnl)
{
    n.InnerText = "";
}

So I understand that modifying the XmlNodeList – modifies the XmlDocument that the node list was taken from.

Is there some way to create a deep copy (I think that’s what I need) of the list of nodes into another XmlElement, so that when I modify these nodes they will be independent of the original location where they were copied from?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:51:36+00:00Added an answer on May 30, 2026 at 3:51 am

    There is more than one way to skin an xml cat. This is just one.

        var xd = new XmlDocument();
        xd.LoadXml("<root><nodes><node>1</node><node>2</node></nodes></root>");
        var xnl = xd.SelectSingleNode("/root/nodes").Clone();
    
        foreach (XmlNode n in xnl)
        {
            n.InnerText = "x";
        }
    
        Console.Out.WriteLine(xd.OuterXml);
        Console.Out.WriteLine("--------------");
        Console.Out.WriteLine(xnl.OuterXml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to load some XML into a document: <Custom AttributeA='' AttributeB='Bob' AttributeC='HUNTERS' COMPANY EMPLOYEES'
Greetings, My goal: To validate an XML document then load the data into a
I have an xml template document that I need to load into an XmlDocument.
I'm loading valid XHTML into an XmlDocument, but it takes 2 seconds to load.
private void BindCountry() { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath(countries.xml)); foreach (XmlNode node in
1) I do a Dataset.WriteToXml(memory stream object) 2) Then i create a XMLDocument object
I'm trying to modify an XmlDocument by deleting nodes from it while I'm iterating
I have a System.XML.Schema.XmlSchema loaded into memory and an XML instance data of element
How can we load an xml document with xquery to be parsed by the
I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.