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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:12:47+00:00 2026-06-09T10:12:47+00:00

I have a string that contains a fair bit of XML, it’s actually xml

  • 0

I have a string that contains a fair bit of XML, it’s actually xml that describes a word document(document.xml). I want to simply replace a part of the string with an empty string effectivally removing it from the string. This sounds straight forward but I’m not getting the result I expect.

Here is what some of the XML looks like, this is just the first 10 lines:

<w:body xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
    <w:p w:rsidR="00CB3A3E" w:rsidP="00257CF7" w:rsidRDefault="008C1E91">
        <w:pPr>
            <w:pStyle w:val="Heading-Title" />
        </w:pPr>
        <w:r>
            <w:t>References</w:t>
        </w:r>
    </w:p>
    <w:sdt> 

As I said this is in a string. I simply try to replace <w:t>References</w:t> with an empty string. I am doing it like so:

//xmlBody is the string that is holding the xml
xmlBody.Replace("<w:t>References</w:t>", " ");

This is not working, the string is unaltered when I do this. What am I doing wrong? Any advice would be appreciated, thanks much!

  • 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-09T10:12:49+00:00Added an answer on June 9, 2026 at 10:12 am
    xmlBody = xmlBody.Replace("<w:t>References</w:t>", "");
    

    The Replace function doesn’t change the source string; it returns a new string with the changes made. In fact, C# strings cannot be changed. If you check out the documentation, it says that they’re immutable.

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

Sidebar

Related Questions

I have a string that contains well formed xml in it. I want to
I have a string that contains ' characters. I want to replace all of
I have a string that contains multiple spaces. I want to replace these with
I have a string that contains html. I want to get all href value
I have a string that contains two numbers and some text. I want to
I have a string that contains IPCM_20120223_xml.tar.gz and i want to change it to
I have a string that contains the following: <span>A</span>BC<span id=blabla>D</span>EF i want to be
I have a String that contains an HTTP header. I want to turn this
I have a string that contains many asterisk' '*'. I want to be able
i have a string that contains a bunch of html. i want to html-encode

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.