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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:00:20+00:00 2026-05-13T20:00:20+00:00

I’ve got the following XML passed as an IQueryable to a method, i.e. XML:

  • 0

I’ve got the following XML passed as an IQueryable to a method, i.e.

XML:

<body>
  <p>Some Text</p>
  <p>Some Text</p>
  <pullquote>This is pullquote</pullquote>
  <p>Some Text</p>
  <p>Some Text</p>
 <body>

Method:

public static string CreateSection(IQueryable<XElement> section)
{
     var bodySection = from b in articleSection.Descendants("body")
                       select b;

     //Do replacement here.

     var bodyElements = bodySection.Descendants();

     StringBuilder paragraphBuilder = new StringBuilder();
     foreach (XElement paragraph in bodyElements)
     {
         paragraphBuilder.Append(paragraph.ToString());
     }

     return paragraphBuilder.ToString();
}

What I want to accomplish is to replace the <pullquote> with a <p> (and maybe add attributes).

My problem is not the actual replacement (XElement.ReplaceWith()) but the fact that after the replacement the changes does not reflect the bodySection variable that gets used by the StringBuilder.

How would I go about getting this to work?

  • 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-13T20:00:20+00:00Added an answer on May 13, 2026 at 8:00 pm

    You haven’t really shown enough code – in particular, you haven’t shown the replacement code you’re trying to use.

    However, I suspect the main problem is that bodySection is a query. Every time you use it, it will query section again – and if that’s pulling information from the database, then so be it. You may find that this is all that’s required to make it do what you want:

    var bodySection = articleSection.Descendants("body").ToList();
    

    That way you’ve then got the body sections in memory, and any time you use bodySection you’ll be using the same collection of objects, rather than querying again.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and

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.