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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:04:13+00:00 2026-06-03T21:04:13+00:00

I have an XML file and I am loading it in Xmldocument. This document

  • 0

I have an XML file and I am loading it in Xmldocument. This document has a node with some child nodes like this

<xml here>
 <somenode>
   <child> </child>
   <children></children>
   <children></children>
   <children></children>  // I need to insert it
   <children></children>  // I need to insert this second time
   <children></children>
   <children></children>
   <child> </child>
 <somenode>
<xml here>

here somenode has some children where first and last children node names are same where as other nodes except the first and last node has some diffrent name ( identical to each other ). I am creating a function to insert a node at specific position, I am not sure about the criteria but may be in the mid.

  • how can I insert node in specific position. I am using XMLnode.appendChild method for insertion
  • Do I need to rearrange/sort nodes after insertion. Please suggest.
  • How can I determine what is structure and how should I find where the new node should be added according to current document structure.
  • 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-06-03T21:04:14+00:00Added an answer on June 3, 2026 at 9:04 pm

    you can use XLinq to modify XML document

    Following is an example of xml modification

        String xmlString = "<?xml version=\"1.0\"?>"+"<xmlhere>"+
        "<somenode>"+
        " <child> </child>"+
        " <children>1</children>"+ //1
        " <children>2</children>"+ //2
        " <children>3</children>"+ // 3, I need to insert it
        " <children>4</children>"+  //4,  I need to insert this second time
        " <children>5</children>"+
        " <children>6</children>"+ 
        " <child> </child>"+
        " </somenode>"+
        "</xmlhere>";
    
        XElement root = XElement.Parse(xmlString);
        var childrens = root.Descendants("children").ToArray();
        var third = childrens[3];
        var fourth = childrens[4];
        third.AddBeforeSelf(new XElement("children"));
        fourth.AddBeforeSelf(new XElement("children"));
    
        var updatedchildren = root.Descendants("children").ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have this XML file here. <?xml version=1.0 encoding=UTF-8?> <xml> <word> <threeletter>RIP</threeletter> <threeletter>PIE</threeletter> <fourletter>PIER</fourletter>
I have a flash file that is loading data from XML file. After I
I have parsed XML file into objects, in which each object has a 1:1
I have an xml file that I need to load. This xml file holds
I have a WIX XML document that contains 2,000+ file tags. I am trying
We have a Flex app that is currently loading an XML file that contains
I have trouble loading an xml file stored on my local network... (you could
I have an XML document file.xml which is encoded in Iso-latin-15 (aka Iso-Latin-9) <?xml
i have the string, it contains xml nodes, returned from the PHP file. It's

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.