Solved

Ignore a quote.

Posted on 2006-07-21
3
257 Views
Last Modified: 2010-04-16
I have a tough one, I'm replacing a text string with "blank" BUT, the text string contains a quote so I'm getting a build error that is expecting a )..

string results = sb.ToString().Replace("<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"","")
I can't escape the quote because then it doesn't replace the striing because it's not exact...

How can I get it to work, any thoughts?
0
Comment
Question by:boukaka
3 Comments
 
LVL 7

Accepted Solution

by:
whatsit2002 earned 500 total points
ID: 17155228
It looks like your quote is in the wrong place. You should put your quotes inside of the brackets like:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd">

Not:
<PolicyDataSet xmlns="http://www.microtrends.net/PolicyDataSet.xsd>"

So, it looks to me that your issue is not escaped double quotes, but misplaced double quotes. The above code would look like:

string results = sb.ToString().Replace("<PolicyDataSet xmlns=\"http://www.microtrends.net/PolicyDataSet.xsd\">","")

Thanks.

Jason
0
 
LVL 6

Expert Comment

by:dorothy2
ID: 17155333
You wouldn't have this problem if the xmlns attribute had single quotes rather than double.

StringBuilder sb = new StringBuilder("This is a test. <PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'> This is the end of the test");
Console.WriteLine("Before: " + sb.ToString());
string results = sb.ToString().Replace("<PolicyDataSet xmlns='http://www.microtrends.net/PolicyDataSet.xsd'>","");
Console.WriteLine("After: " + results);


Can you make this change easily? If not, you could use regular expressions to change the double quotes to single quotes before you call Replace().

Dorothy
0
 

Author Comment

by:boukaka
ID: 17155811
I moved the quote and it worked perfectly!!! Thank you so much, I was going insane.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now