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 53507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:04:27+00:00 2026-05-10T17:04:27+00:00

I have an XmlDocument that already exists and is read from a file. I

  • 0

I have an XmlDocument that already exists and is read from a file.

I would like to add a chunk of Xml to a node in the document. Is there a good way to create and add all the nodes without cluttering my code with many .CreateNote and .AppendChild calls?

I would like some way of making a string or stringBuilder of a valid Xml section and just appending that to an XmlNode.

ex: Original XmlDoc:

<MyXml>    <Employee>    </Employee> </MyXml> 

and, I would like to add a Demographic (with several children) tag to Employee:

<MyXml>    <Employee>       <Demographic>          <Age/>          <DOB/>       </Demographic>    </Employee> </MyXml> 
  • 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. 2026-05-10T17:04:28+00:00Added an answer on May 10, 2026 at 5:04 pm

    I suggest using XmlDocument.CreateDocumentFragment if you have the data in free form strings. You’ll still have to use AppendChild to add the fragment to a node, but you have the freedom of building the XML in your StringBuilder.

    XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(@'<MyXml><Employee></Employee></MyXml>');  XmlDocumentFragment xfrag = xdoc.CreateDocumentFragment(); xfrag.InnerXml = @'<Demographic><Age/><DOB/></Demographic>';  xdoc.DocumentElement.FirstChild.AppendChild(xfrag); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML document that I would like to update after it already
I have an XML document that I generate from an Entity Framework object. The
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
I have an XML document that matches our site navigation something like this: <page
I have a C# class method that return a xml document not file. How
I have a XML file like this: <Document> <Tests> <Test> <Name>A</Name> <Value>1</Value> </Test> <Test>
In my Python app, I have an XML document that I'd like to transform
I have an XmlDocument object that I load from a file. XmlDocument xmlDoc =
I have a xml document that has a record set like this. <document> <row>
I have an XML file that already contains a reference to an XSLT file.

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.