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

  • Home
  • SEARCH
  • 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 4267476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:54:17+00:00 2026-05-21T06:54:17+00:00

If I want to add, update or delete node in the xml using c#,

  • 0

If I want to add, update or delete node in the xml using c#, how can it be done? My xml is shown below. I dont want transactionID node. I want to add a node called <Transformation>XML</Transformation> after corelationID node.

<?xml version="1.0" ?>
<GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
    <EnvelopeVersion>2.0</EnvelopeVersion>
    <Header>
        <MessageDetails>
            <Class>HMRC-VAT-DEC</Class>
            <Qualifier>poll</Qualifier>
            <Function>submit</Function>
            <TransactionID />
            <CorrelationID>1B93D48C02D740C6B79DE68A27F3ADE5</CorrelationID>
            <ResponseEndPoint PollInterval="10">https://secure.dev.gateway.gov.uk/poll</ResponseEndPoint>
            <GatewayTimestamp>2011-04-05T07:41:43.018</GatewayTimestamp>
        </MessageDetails>
        <SenderDetails />
    </Header>
    <GovTalkDetails>
        <Keys />
    </GovTalkDetails>
    <Body />
</GovTalkMessage>
  • 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-21T06:54:18+00:00Added an answer on May 21, 2026 at 6:54 am
    //Load the XML
        XmlDocument documentXML = new XmlDocument();
        documentXML.Load(Server.MapPath("AddDeleteUpdate.xml"));
    
        XmlNamespaceManager xmlns = new XmlNamespaceManager(documentXML.NameTable);
        xmlns.AddNamespace("bk", "http://www.govtalk.gov.uk/CM/envelope");
    
        //Identify the parent node i.e <MessageDetails>
        XmlNode nodeMessage = documentXML.SelectSingleNode("//bk:GovTalkMessage/bk:Header/bk:MessageDetails", xmlns);
    
        //Delete the node.
        XmlNode nodeTransactionID = documentXML.SelectSingleNode("//bk:GovTalkMessage/bk:Header/bk:MessageDetails/bk:TransactionID", xmlns);
        nodeMessage.RemoveChild(nodeTransactionID);
    
        //Create the new XML noded to be added.
        XmlNode controlAttrNode = null;
        controlAttrNode = documentXML.CreateElement("Transformation");
        controlAttrNode.InnerText = "XML";
        controlAttrNode.Attributes.RemoveAll();
    
        //Get the node object to where it need to be added.
        XmlNode nodeCorrelation = documentXML.SelectSingleNode("//bk:GovTalkMessage/bk:Header/bk:MessageDetails/bk:CorrelationID", xmlns);
        //Insert the node after.
        nodeMessage.InsertAfter(controlAttrNode, nodeCorrelation);
    
        documentXML.Save(Server.MapPath("AddDeleteUpdate.xml"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several wpf pages with update/delete/add buttons. I want to display to the
Often I want to add a value to a table or update the value
Dynamically I want to edit/update hosts(etc/hosts) file to add domain. To edit hosts(etc/hosts) file
i want to build a tree in java. operations such as insert delete update.
I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton
Quite often i need to add/delete/update the item in database via Jquery POST. Now
i try to write a kind of repository for effective Add,Update, Delete etc. But
i m new here, i want to update and delete the records from the
I did one small application of contact system for add update and delete.Now making
My database is currently using the InnoDB engine. Now I want to add 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.