473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

removing back slash character from a string

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.
Oct 9 '08 #1
8 4030
"andrew" <an****@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
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.
The Replace function creates a new string - it does not modify the original
string.

E.g.

string strTest = "Hello";
strTest.Replace("o", ""); // strTest is not modified
strTest = strTest.Replace("o", "") // strTest now contains "Hell"
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 9 '08 #2
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.
Oct 9 '08 #3
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
Oct 9 '08 #4
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.
Oct 9 '08 #5
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" <an****@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
>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.
Oct 9 '08 #6
"Hillbilly" <so******@somewhere.comwrote in message
news:u6**************@TK2MSFTNGP04.phx.gbl...
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?
Oct 9 '08 #7
>>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.
Oct 9 '08 #8
Thank you, here's the correct URL...
http://www.r2musings.com/2008/01/18/...FromAPath.aspx

"Jeff Dillon" <je********@hotmailremove.comwrote in message
news:O6**************@TK2MSFTNGP03.phx.gbl...
"Hillbilly" <so******@somewhere.comwrote in message
news:u6**************@TK2MSFTNGP04.phx.gbl...
>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?
Oct 9 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Stephen Ferg | last post by:
I have a question that is not directly Python-related. But I thought I'd ask the most erudite group that I know... :-) When did Windows start accepting the forward slash as a path separator...
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
16
by: junky_fellow | last post by:
Is there any efficcient way of removing the newline character from the buffer read by fgets() ? Is there any library function that is similar to fgets() but also tells how many bytes it read...
6
by: dansolo | last post by:
Hi to all, I have to compare two strings in which there is the character \, for example: "hello\r, bye\n" but the second string, which is taken from a mysql db, has the following form ...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
23
by: dkirkdrei | last post by:
I am having a bit of trouble trying to double up on slashes in a file path. What I am trying to do is very similar to the code below: <? $var =...
4
by: destroooooy | last post by:
Hi folks, I'm finding some (what I consider) curious behavior with the string methods and the forward slash character. I'm writing a program to rename mp3 files based on their id3 tags, and I want...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.