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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:50:29+00:00 2026-06-09T07:50:29+00:00

I have an xml file like this, <?xml version=1.0 encoding=utf-8 ?> <root> <FeaturedProductCategories> <FeaturedProductCategory>

  • 0

I have an xml file like this,

<?xml version="1.0" encoding="utf-8" ?>
<root>  
  <FeaturedProductCategories>
    <FeaturedProductCategory>
      <FeaturedProducts>
        <FeaturedProduct>
          <ContentSelector datavalue_idtype="content:smartform" datavalue_displayvalue="«Smart Form:49»">49</ContentSelector>
        </FeaturedProduct>
      </FeaturedProducts>
    </FeaturedProductCategory>
  </FeaturedProductCategories>
</root>

I want to modify it like the one below,

<?xml version="1.0" encoding="utf-8" ?>
<root>
  <Title>HomePage</Title>
  <FeaturedProductCategories>
    <FeaturedProductCategory>
      <FeaturedProducts>
        <FeaturedProduct>
          <Products>
            <Product>
              <ProductTitle>Product</ProductTitle>
              <ProductDate>03-08-2012 11:57:25</ProductDate>
              <ProductImage>
                <img src="ex1.jpg" />
              </ProductImage>
              <ProductThumbnailImage>
                <img src="ex2.jpg" />
              </ProductThumbnailImage>
              <ProductCaption>Product Caption</ProductCaption>
              <ProductImage>
                <img src="ex3.jpg" />
              </ProductImage>
              <ProductThumbnailImage>
                <img src="ex4.jpg" />
              </ProductThumbnailImage>
              <ProductCaption>Product Caption</ProductCaption>
            </Product>
          </Products>
        </FeaturedProduct>
      </FeaturedProducts>
    </FeaturedProductCategory>
  </FeaturedProductCategories>
</root>

All the new nodes and values are to be added through a C# function. Let us assume these new values as static values for now.

Also the node “FeaturedProduct” is not only one. There are a lot of nodes in that name. I want to modify all the “FeaturedProduct” nodes.

  • 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-09T07:50:30+00:00Added an answer on June 9, 2026 at 7:50 am

    This doesn’t use linq exactly, but It will serve your purpose

            XmlDocument xDoc = new XmlDocument();
            xDoc.Load("filename.xml");
    
            foreach (XmlNode xNode in xDoc.SelectNodes("//FeaturedProduct"))
            {
                XmlElement newElement = xDoc.CreateElement("newElementName");
                XmlAttribute newAttribute = xDoc.CreateAttribute("AttributeName");
                newAttribute.Value = "attributeValue";
                newElement.Attributes.Append(newAttribute);
    
                xNode.AppendChild(newElement);
                xNode.InnerText = "myInnerText";
            }
    

    Also, This Documentation is a very handy reference for Xpath

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

Sidebar

Related Questions

I have a XML file, like this: <?xml version=1.0 encoding=utf-8 ?> <ROOT> <NAME> ItemName
I have a XML file like this <?xml version=1.0 encoding=utf-8?> <Survey Name=Aerosmith's Survey Id=S2
I have created an xml file like this: <?xml version=1.0 encoding=utf-8?> <ListView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
I have an XML file looks like this: <?xml version=1.0 encoding=utf-8 ?> <PathMasks> <Mask
I have an options_menu.xml file like this: <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item android:id=@+id/search
If I have a xml file with something like this: <?xml version=1.0 encoding=utf-8 ?>
I have an XML file that looks like this: <?xml version=1.0? encoding=UTF-8 standalone=no?> <dir
I have an xml document like this: <?xml version=1.0 encoding=UTF-8?> <foo:root xmlns:foo=http://abc.com# xmlns:bar=http://def.com xmlns:ex=http://ex.com>
I have an XML File that looks like this: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
So say I have this XML file: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root> <Category Name=Tasties>

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.