Click here to Skip to main content
15,909,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If i want to delete an xml node,update an existing node and add a new node in the following xml sample using c#, what should i do?
XML
<?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>
Posted

Member 7794889308 wrote:
If i want to delete an xml node,update an existing node and add a new node in the following xml sample using c#, what should i do?


I suggest you take a look at this.

Manipulate XML File Data Using C#[^]
 
Share this answer
 
If the files are relatively small, the simplest way is using DOM. Use System.Xml.XmlDataDocument.

Note: you should not ever work with XML nodes directly. In case of DOM, you read full XML document, manipulate DOM nodes (they have one-to-one correspondence with XML Elements and Attributes, but they are not the same). The main class you will work is System.Xml.XmlNode, as well as derived classes. Take a look at the help of those classes; and you will immediately see how to manipulate them.

—SA
 
Share this answer
 
Comments
Guyverthree 5-Apr-11 4:37am    
I like this good answer
Sergey Alexandrovich Kryukov 5-Apr-11 4:39am    
Thank you, Safar.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900