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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:49:37+00:00 2026-06-13T11:49:37+00:00

I have an XML document below and there is a tag called <FormData> in

  • 0

I have an XML document below and there is a tag called <FormData> in side this tag it as an attribute called FormId=”d617a5e8-b49b-4640-9734-bc7a2bf05691″

I would like to change that value in C# code?

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(MapPath(tempFolderPathAlt + "dvforms" + "\\XmlDataTemplate.xml"));
    //Change value of FormID
    xmlDoc.Save(tempFolderPath + "data.xml");

Be is my XML document:

<?xml version="1.0"?>
<FormData Platform="Android" PlatformVersion="100" Version="966" DataVersion="1" Description="Investec - Res" FormId="d617a5e8-b49b-4640-9734-bc7a2bf05691" FileId="e6202ba2-3658-4d8e-836a-2eb4902d441d" EncryptionVerification="" CreatedBy="Bob" EditedBy="Bob">
<FieldData>
<request_details_export_template Mod="20010101010101" IncludeInPDFExport="Yes"></request_details_export_template>
<request_details_reason_for_valuatio Mod="20010101010101" IncludeInPDFExport="Yes"></request_details_reason_for_valuatio>
</FieldData>
<Photos Mod="20010101010101"/>
<VoiceNotes/>
<Drawings Mod="20010101010101"/>
<FieldNotes/>
</FormData>
  • 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-13T11:49:38+00:00Added an answer on June 13, 2026 at 11:49 am

    There are several ways of doing this, including:

    XmlAttribute formId = (XmlAttribute)xmlDoc.SelectSingleNode("//FormData/@FormId");
    if (formId != null)
    {
        formId.Value = "newValue"; // Set to new value.
    }
    

    Or this:

    XmlElement formData = (XmlElement)xmlDoc.SelectSingleNode("//FormData");
    if (formData != null)
    {
        formData.SetAttribute("FormId", "newValue"); // Set to new value.
    }
    

    The SelectSingleNode method uses XPath to find the node; there is a good tutorial about XPath here. Using SetAttribute means the FormId attribute will be created if it does not already exist, or updated if it does already exist.

    In this case, FormData happens to be the document’s root element, so you can also do this:

    xmlDoc.DocumentElement.SetAttribute("FormId", "newValue"); // Set to new value.
    

    This last example will only work where the node you are changing happens to be the root element in the document.

    To match a specific FormId guid (it is not clear if this is what you wanted):

    XmlElement formData = (XmlElement)xmlDoc.SelectSingleNode("//FormData[@FormId='d617a5e8-b49b-4640-9734-bc7a2bf05691']");
    if (formData != null)
    {
        formData.SetAttribute("FormId", "newValue"); // Set to new value.
    }
    

    Note that the select in this last example returns the FormData element and not the FormId attribute; the expression in [] brackets enables us to search for a node with a particular matching attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some xml XML Document with duplicate tag names like below :: <ROOT>
I have an XML document containing contact information as seen below: <contact type=individual> <firstname>Some</firstname>
I have following CDATA inside xml document: <![CDATA[ <p xmlns=>Refer to the below: <br/>
I have an XML document, and I want to print the tag names and
I have a document that it's structure is like below. There are a lot
I have an XML document with (basically) looks like this: ... <param> <key>age</key> <value>10</value>
I have an xml document that looks something like below (resources.xml), with a corresponding
I have an XML document that I'm trying to search through. The Main structure
I have an XML document composed of several other XML documents appended to it.
I have an XML document with a default namespace indicated at the root. Something

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.