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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:48:19+00:00 2026-06-16T09:48:19+00:00

Looking to add an attribute to an existing xml element <D_COMMS> , not replace

  • 0

Looking to add an attribute to an existing xml element <D_COMMS>, not replace the existing attribute just add it to the beginning.

This is the XML

<OUTPUT version="2.0">
 <RESPONSE>
  <DATA id="17fb13cca6c5463597fdf340c044069f">
    <![CDATA[<ID> jdfkldklfjdkl</ID><D_COMMS>ON this date...</D_COMMS>]]>
  </DATA>
 </RESPONSE>

This XML is the result of a HTTPWebResponse so this is what the XMl looks like when it comes back to me and I need to add a value to the D_COMMS element and send it back.Tried something like this to look for the descendant DATA and add it that way.

var addelement = doc.Descendants("DATA").First();
addelement.Add(XElement("D_COMMS","On this date we said"));
  • 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-16T09:48:20+00:00Added an answer on June 16, 2026 at 9:48 am

    You can find the DATA node and add an attribute as follows:

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xml);
    XmlNodeList dataNodes = doc.GetElementsByTagName("DATA");
    if (dataNodes != null && dataNodes.Count > 1)
    {
        dataNodes[0].Attributes.Append(doc.CreateAttribute("D_COMMS", "On this date we said"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to add an xml element and attribute between an existing one. I have
I'm looking for a regex expression that will add an attribute to an element
I'm looking to add double buffering to a drawing function like this. dc =
I am looking to add an ORM to my existing Sinatra app. I went
I'm looking to add the post ID to the markup of wp_nav_menu but not
I want to be able to add an attribute to a HTML element to
I'm looking to add an attribute (href) into a td of a table. I
I'm looking for a way to add attributes to xml tags in python. Or
I want to add an attribute to every tag in my xml, which is
We are looking for a solution to add a CSS class attribute to a

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.