Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > removing back slash character from a string

Reply
Thread Tools

removing back slash character from a string

 
 
andrew
Guest
Posts: n/a
 
      10-09-2008
I have a weird scenario where I'm trying to use a schema that was loaded into
an XmlDocument.

When I try to use that document later (myXDOC.OuterXml)... my text contains
back slash values in front of every quotation mark and I can't seem to get
rid of them.

myXDOC.OuterXml.Replace("\\","") doesn't work.
myXDOC.OuterXml.Replace(@"\","") doesn't work.
myXDOC.OuterXml.Replace("\"c,""c) won't compile.
 
Reply With Quote
 
 
 
 
K Viltersten
Guest
Posts: n/a
 
      10-09-2008
> myXDOC.OuterXml.Replace("\\","") doesn't work.
> myXDOC.OuterXml.Replace(@"\","") doesn't work.
> myXDOC.OuterXml.Replace("\"c,""c) won't compile.


What do you mean by "doesn't work"? Compile errors?
Strange functionality? May i be as bold as to suggest
that you might have assumed that Replace-method is
of type void (while it's of type string, ennoyingly
surprising)? Please elaborate.

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.


 
Reply With Quote
 
 
 
 
Lloyd Sheen
Guest
Posts: n/a
 
      10-09-2008
K Viltersten wrote:
>> myXDOC.OuterXml.Replace("\\","") doesn't work.
>> myXDOC.OuterXml.Replace(@"\","") doesn't work.
>> myXDOC.OuterXml.Replace("\"c,""c) won't compile.

>
> What do you mean by "doesn't work"? Compile errors?
> Strange functionality? May i be as bold as to suggest
> that you might have assumed that Replace-method is
> of type void (while it's of type string, ennoyingly
> surprising)? Please elaborate.
>

I didn't see first part of the post but if you are expecting the
contents of myXDOC to change, that is your problem. You have to assign
the value of myXDOC.OuterXml.Replace(WHATEVER) to itself. Replace is a
function and returns a string so your code would most likely look like:

myXDOC.OuterXml = myXDOC.OuterXml.Replace(WHATEVER)

LS
 
Reply With Quote
 
andrew
Guest
Posts: n/a
 
      10-09-2008
Well I was using those lines within a method call... therefore the method
would end up with the altered string...

Ultimately my issue wasn't the backslash characters... the schema that I was
having trouble with didn't have an XML declaration at the top... as do all
the rest of our schemas... that's why when streaming out the text the browser
wasn't displaying anything and it wasn't the back slashes after all.

"K Viltersten" wrote:

> > myXDOC.OuterXml.Replace("\\","") doesn't work.
> > myXDOC.OuterXml.Replace(@"\","") doesn't work.
> > myXDOC.OuterXml.Replace("\"c,""c) won't compile.

>
> What do you mean by "doesn't work"? Compile errors?
> Strange functionality? May i be as bold as to suggest
> that you might have assumed that Replace-method is
> of type void (while it's of type string, ennoyingly
> surprising)? Please elaborate.
>
> --
> Regards
> Konrad Viltersten
> ----------------------------------------
> May all spammers die an agonizing death;
> have no burial places; their souls be
> chased by demons in Gehenna from one room
> to another for all eternity and beyond.
>
>
>

 
Reply With Quote
 
Hillbilly
Guest
Posts: n/a
 
      10-09-2008
As it turns out this blogged trailing slash topic [1] was found just this
week

[1]
http://blogs.msdn.com/gerryo/archive...ification.aspx


"andrew" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a weird scenario where I'm trying to use a schema that was loaded
>into
> an XmlDocument.
>
> When I try to use that document later (myXDOC.OuterXml)... my text
> contains
> back slash values in front of every quotation mark and I can't seem to get
> rid of them.
>
> myXDOC.OuterXml.Replace("\\","") doesn't work.
> myXDOC.OuterXml.Replace(@"\","") doesn't work.
> myXDOC.OuterXml.Replace("\"c,""c) won't compile.


 
Reply With Quote
 
Jeff Dillon
Guest
Posts: n/a
 
      10-09-2008
"Hillbilly" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> As it turns out this blogged trailing slash topic [1] was found just this
> week
>
> [1]
> http://blogs.msdn.com/gerryo/archive...ification.aspx
>


I think you posted the wrong URL?


 
Reply With Quote
 
K Viltersten
Guest
Posts: n/a
 
      10-09-2008
>>> myXDOC.OuterXml.Replace("\\","") doesn't work.
>>> myXDOC.OuterXml.Replace(@"\","") doesn't work.
>>> myXDOC.OuterXml.Replace("\"c,""c) won't compile.

>>
>> What do you mean by "doesn't work"? Compile errors?
>> Strange functionality? May i be as bold as to suggest
>> that you might have assumed that Replace-method is
>> of type void (while it's of type string, ennoyingly
>> surprising)? Please elaborate.
>>

> I didn't see first part of the post but if you are expecting the contents
> of myXDOC to change, that is your problem.


I don't expect that. However, i forget this, every
now and then.

> You have to assign the value...


Yes, that's the point of what i wrote. Perhaps not
clear enough. The method is not a void, but string
type. Hence, one needs to catch the result of it.

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.


 
Reply With Quote
 
Hillbilly
Guest
Posts: n/a
 
      10-09-2008
Thank you, here's the correct URL...
http://www.r2musings.com/2008/01/18/...FromAPath.aspx

"Jeff Dillon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Hillbilly" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> As it turns out this blogged trailing slash topic [1] was found just this
>> week
>>
>> [1]
>> http://blogs.msdn.com/gerryo/archive...ification.aspx
>>

>
> I think you posted the wrong URL?
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert string with control character in caret notation to realcontrol character string. Bart Vandewoestyne C Programming 8 09-25-2012 12:41 PM
string replace for back slash rdmurray@bitdance.com Python 0 02-05-2009 12:29 PM
Re: string replace for back slash Chris Rebert Python 0 02-05-2009 11:59 AM
8 bit character string to 16 bit character string Brand Bogard C Programming 8 05-28-2006 05:05 PM
Javascript Functions Back Slash! adam_a_knight@hotmail.com Javascript 4 06-26-2004 05:10 PM



Advertisments