473,320 Members | 1,746 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,320 software developers and data experts.

Backslash "\" is being added to XML Attributes, Is there a way to get rid off it?

I have not encountering this problem 'till I got VS.NET 2003. Check my xml
below how the backlash is added. I tried all possible ways to replace it but
nothing happens. Any help will greatly appreciated.

<SESSION_INFO_ID ID=\"434674640\">
<TEL_NBR VALUE=\"2532668900\">
<PRODUCT hcid=\"1600\"></PRODUCT>
<PRODUCT hcid=\"1700\"></PRODUCT>
</TEL_NBR>
</SESSION_INFO_ID>
Nov 12 '05 #1
8 11952
Pete wrote:
I have not encountering this problem 'till I got VS.NET 2003. Check my xml
below how the backlash is added. I tried all possible ways to replace it but
nothing happens. Any help will greatly appreciated.

<SESSION_INFO_ID ID=\"434674640\">
<TEL_NBR VALUE=\"2532668900\">
<PRODUCT hcid=\"1600\"></PRODUCT>
<PRODUCT hcid=\"1700\"></PRODUCT>
</TEL_NBR>
</SESSION_INFO_ID>


Most likely that's visual effect produced by Visual Studio. It's
property inspector and debugging windows "feature".

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
As I said below I never encounter this in previous version. I used this xml
to pass to my stored procedure and due to that character it breaks the sp.

Here is the code snipet how I build the xml

StringWriter strWriter = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(strWriter);

writer.WriteAttributeString("session_info_id", "434674640");

.......

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:OG**************@tk2msftngp13.phx.gbl...
Pete wrote:
I have not encountering this problem 'till I got VS.NET 2003. Check my xml below how the backlash is added. I tried all possible ways to replace it but nothing happens. Any help will greatly appreciated.

<SESSION_INFO_ID ID=\"434674640\">
<TEL_NBR VALUE=\"2532668900\">
<PRODUCT hcid=\"1600\"></PRODUCT>
<PRODUCT hcid=\"1700\"></PRODUCT>
</TEL_NBR>
</SESSION_INFO_ID>


Most likely that's visual effect produced by Visual Studio. It's
property inspector and debugging windows "feature".

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #3
Pete wrote:
As I said below I never encounter this in previous version. I used this xml
to pass to my stored procedure and due to that character it breaks the sp.

Here is the code snipet how I build the xml

StringWriter strWriter = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(strWriter);

writer.WriteAttributeString("session_info_id", "434674640");


I don't believe this code produces that XML with slashes. As I said most
likely that's visual effect - there are no slashes in XML, but Visual
Studio .NET has a "feature" of showing slashes before quotes in property
inspector and debug windows.
Make sure there are really those slashes in XML - output it to console
or file.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
I don't want to argue with you but have you tried that class and writing
attributes?

Even my xsl transformation wouldn't recognize this crap.

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
Pete wrote:
As I said below I never encounter this in previous version. I used this xml to pass to my stored procedure and due to that character it breaks the sp.
Here is the code snipet how I build the xml

StringWriter strWriter = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(strWriter);

writer.WriteAttributeString("session_info_id", "434674640");


I don't believe this code produces that XML with slashes. As I said most
likely that's visual effect - there are no slashes in XML, but Visual
Studio .NET has a "feature" of showing slashes before quotes in property
inspector and debug windows.
Make sure there are really those slashes in XML - output it to console
or file.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #5
Pete wrote:
I don't want to argue with you but have you tried that class and writing
attributes?
Well, have I tried XmlTextWriter? Sure :) It writes wellformed XML with
no backslashes whatsoever. It's a class from System.Xml namespace, you
can trust it.
Provide more info, may be reproducible sample etc. Should be some silly
error somewhere.
Even my xsl transformation wouldn't recognize this crap.


What do you mean exactly? Any exceptions?

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6
Put this in your aspx.
StringWriter strWriter = new StringWriter();

XmlTextWriter writer = new XmlTextWriter(strWriter);

writer.WriteStartElement("SESSION_INFO_ID");

writer.WriteStartElement("TEL_NBR");

writer.WriteAttributeString("VALUE=","4258009000"

writer.WriteAttributeString("EXTN=","9000");

writer.WriteAttributeString("NAME=","Oleg Tkachenko XML MVP")

writer.WriteEndElement();

writer.WriteEndElement();

string input = strWriter.ToString();

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl...
Pete wrote:
I don't want to argue with you but have you tried that class and writing
attributes?


Well, have I tried XmlTextWriter? Sure :) It writes wellformed XML with
no backslashes whatsoever. It's a class from System.Xml namespace, you
can trust it.
Provide more info, may be reproducible sample etc. Should be some silly
error somewhere.
Even my xsl transformation wouldn't recognize this crap.


What do you mean exactly? Any exceptions?

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #7
Pete wrote:
Put this in your aspx.
Here is the result:

<SESSION_INFO_ID><TEL_NBR VALUE=="4258009000" EXTN=="9000" NAME=="Oleg
Tkachenko XML MVP" /></SESSION_INFO_ID>

No backslashes. Well, those == is definitely not well-formed. That's
known limitation of XmlTextWriter - it doesn't check names for validity.
See
http://msdn.microsoft.com/library/en...asp?frame=true
writer.WriteAttributeString("EXTN=","9000");
This is obviously wrong. First argument of WriteAttributeString is "The
local name of the attribute". Use
writer.WriteAttributeString("EXTN","9000");
writer.WriteEndElement();


Here you better close XmlTextWriter to flush the content:

writer.Close();
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #8
Thanks!!

I run a profiler and the xml passes to the sp doesn't have backslashes. You
were right it was just a visual effect.

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
Pete wrote:
Put this in your aspx.
Here is the result:

<SESSION_INFO_ID><TEL_NBR VALUE=="4258009000" EXTN=="9000" NAME=="Oleg
Tkachenko XML MVP" /></SESSION_INFO_ID>

No backslashes. Well, those == is definitely not well-formed. That's
known limitation of XmlTextWriter - it doesn't check names for validity.
See

http://msdn.microsoft.com/library/en...omizedxmlwrite
rcreation.asp?frame=true
writer.WriteAttributeString("EXTN=","9000");


This is obviously wrong. First argument of WriteAttributeString is "The
local name of the attribute". Use
writer.WriteAttributeString("EXTN","9000");
writer.WriteEndElement();


Here you better close XmlTextWriter to flush the content:

writer.Close();
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #9

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

Similar topics

5
by: Paul Miller | last post by:
We've run into minidom's inabilty to handle large (20+MB) XML files, and need a replacement that can handle it. Unfortunately, we're pretty dependent on a DOM, so a pulldom or SAX replacement is...
0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
8
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
2
by: Johann Blake | last post by:
I posted a related problem today. The problem is this: string str1 = @""""; When I execute this code (even in a bare bones application), in the IDE it returns "\""" Why? Even in the...
19
by: Alan J. Flavell | last post by:
The story so far: on somewhat unrelated newsgroup, my attention fell upon the URL: http://www.speedtouchdsl.com/prod706.htm which contains a link to the purported URL:...
2
by: JPS | last post by:
I need to build a string with just one backslash included "\", but I keep getting an error message unless I use "\\". The double backslashes will not work with what I am doing.
45
by: Umesh | last post by:
please help. thanks.
2
by: Bostonian | last post by:
I am loading an Xml from a physical file and passing it to XSL transformation. When i load the file (C# code), InnerXML shows backslash before all the XML attributes. Xsl transformation crashes...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.