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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:10:24+00:00 2026-05-27T22:10:24+00:00

XML File <?xml version=1.0 encoding=utf-8?> <Section xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema name=Information Section> <ID></ID> <alternateID /> <familyName></familyName>

  • 0

XML File

<?xml version="1.0" encoding="utf-8"?>
<Section xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Information Section">
  <ID></ID>
  <alternateID />
  <familyName></familyName>
  <givenName></givenName>
  <birthDate></birthDate>
  <age></age>
  <height />
  <weight />
  <sex></sex>
  <Address>
    <street1 />
    <street2 />
    <city />
    <state />
    <zipCode />
    <country />
  </Address>
</Section>

I have this empty xml template. I am wondering to how to update / insert value in the elements of this xml using LInq?

Thats what I am trying… needs direction…

 var Doc = XDocument.Load("Info.xml");
    var items = from i in Doc.Descendants("Section")
                select new
                {
                  ID = p.Element("ID").Value
                }
    foreach (var item in items)
          item.id = "VALUE"
??????
  • 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-27T22:10:25+00:00Added an answer on May 27, 2026 at 10:10 pm

    You are currently creating a list of anonymous type objects with

     from i in Doc.Descendants("Section")
     select new { ... }
    

    Instead, create a list of elements to update:

    var items = from i in Doc.Descendants("Section")
         select i;
    
    foreach (var item in items)
    {
       item.Element("ID").Value = "VALUE";
       item.Element("Foo").Value = "Foo";
    }
    Doc.Save(...);
    

    Note that XML is case-sensitive.

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

Sidebar

Related Questions

I've got the following xml file: <?xml version=1.0 encoding=utf-8?> <Project ToolsVersion=4.0 DefaultTargets=DeployPrototype xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup>
This is my XML File. <?xml version=1.0 encoding=utf-8?> <locstrings> <section name=section1> <locstring ID=sectionID1> <Name>SectionName1</Name>
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <doc> <head> <title>Introduction</title> <section>section</section> <channel>testing/test</channel> </head>
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I created an App.config file in my WPF application: <?xml version="1.0" encoding="utf-8" ?> <configuration>
I have XML-file with settings like this <?xml version=1.0 encoding=utf-8 ?> <configuration> <configSections> <sectionGroup
The XML file structure is like this. <?xml version=1.0 encoding=UTF-8?> <Application> <Tabs> <Tab name=1>
I have an XML File <?xml version=1.0 encoding=UTF-8?> <data> <contact-information> <full-name>Peter John</full-name> <address_line_1>some place</address_line_1>
I have this XML file: <?xml version=1.0 encoding=UTF-8 standalone=no?> <games> <game id=123456 name=501> <player
I've got an app.config file, which contains the following <?xml version=1.0 encoding=utf-8 ?> <configuration>

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.