Solved

Ignore a quote.

Posted on 2006-07-21
3
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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