Solved

Ignore a quote.

Posted on 2006-07-21
3
261 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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