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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:56:52+00:00 2026-06-03T13:56:52+00:00

I am trying to delete then add a pageFooter to an xml document from

  • 0

I am trying to delete then add a pageFooter to an xml document from a different file:

XNamespace rep = "http://developer.cognos.com/schemas/report/8.0/";

//remove pageFooter
doc.Root.Descendants().Where(e=>e.Name == rep + "pageFooter").Remove();

//create and load pagefooter from file
XElement pageFooter = XElement.Load(@"C:\pageFooter.xml");

and I am getting the empty namespace:

<pageFooter xmlns="">
    <contents>
         ..............

I tried all of the following to add the namespace to the new element, nothing works:

XElement pagefooter = new XElement(rep+"pageFooter"); 
pageFooter = XElement.Load(@"C:\pageFooter.xml");        
//this has no effect

pageFooter.Name = rep.GetName(pageFooter.Name.LocalName);
//this moves the xmlns="" to the next descendant, <contents>

pageFooter.Add(rep);   
//this has no effect

pageFooter.SetAttributeValue("xmlns", rep);
//this results an empty pageFooter

Any ideas? Thanks!!

  • 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-03T13:56:53+00:00Added an answer on June 3, 2026 at 1:56 pm

    You were on the right track with your second effort listed. The moving of xmlns="" to the next descendant means that pageFooter had the right xmlns, but the rest of its descendants didn’t. Use this:

    foreach (var d in pagefooter.DescendantsAndSelf())
        d.Name = rep + d.Name.LocalName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find a row and then delete that row from a
I'm trying to delete all Usergroups that belongs to one User and then add
I am trying to Add and delete from an arraylist of a collection of
I am trying to read/update/delete the XML file on the basis of value found.
I'm trying to convert bmp files in a folder to jpg, then delete the
I am trying to delete an old user from our perforce installation. A previous
i am trying to delete some files using a batch file.. (winxp) my problem
I'm trying to delete an int[] from an ArrayList. Due to my code I
I am trying to delete a user from an Active Directory group via code.
I'm trying to delete all the markers from my map when the user presses

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.