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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:57:25+00:00 2026-06-10T04:57:25+00:00

How to add or give the parent node for set of nodes in xmlDocument

  • 0

How to add or give the parent node for set of nodes in xmlDocument using vb.net.

I am having following xml nodes

<books>
   <title>title</title>
   <isbn>123456</isbn>
   <surname>surname</surname>
   <givenname>givenname</givenname>
</books>

Now i want to add parent node <author> for <surname> and <givenname> as follows.

 <books>
   <title>title</title>
   <isbn>123456</isbn>
   <author>
      <surname>surname</surname>
      <givenname>givenname</givenname>
   </author>
 </books>

can any one tell me how to do it in xmlDocument in vb.net.

  • 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-10T04:57:26+00:00Added an answer on June 10, 2026 at 4:57 am

    You need to:

    1. Get the parent node that you want to modify (books).
    2. Add the new child element (author).
    3. Get the child elements you want to move (surname and givenname).
    4. For each node you want to move, remove it from it’s parent node (books) and then add it as a child to the new parent node (author).

    For instance:

    Dim doc As New XmlDocument()
    doc.Load(xmlFilePath)
    Dim bookToModify As XmlNode = doc.SelectSingleNode("/books")
    Dim author As XmlNode = doc.CreateElement("author")
    bookToModify.AppendChild(author)
    For Each node As XmlNode In bookToModify.SelectNodes("surname | givenname")
        node.ParentNode.RemoveChild(node)
        author.AppendChild(node)
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with the Java Calendar add() functionality. The give or take
Could somebody give me a pointer on why I need to add my project
So here's my schema (give or take): cmds.Add(@CREATE TABLE [Services] ([Id] INTEGER PRIMARY KEY,
I want to give users the possibility to dynamically add new columns at the
I was wondering how I give the user the new add-ons after they purchase
Is it possible and how to give permissions to issue Reporters to add watchers
In iphone I add twitter framework. When I am run that project it give
I am using BubbleEvent to give events from a web user control to its
I'm using a small tree/graph package ( django_dag ) that has that give my
I have jcarousel set up to scroll through a bunch of images using the

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.