473,728 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_I D ID=\"434674640\ ">
<TEL_NBR VALUE=\"2532668 900\">
<PRODUCT hcid=\"1600\"></PRODUCT>
<PRODUCT hcid=\"1700\"></PRODUCT>
</TEL_NBR>
</SESSION_INFO_ID >
Nov 12 '05 #1
8 12031
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_I D ID=\"434674640\ ">
<TEL_NBR VALUE=\"2532668 900\">
<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(s trWriter);

writer.WriteAtt ributeString("s ession_info_id" , "434674640" );

.......

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:OG******** ******@tk2msftn gp13.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_I D ID=\"434674640\ ">
<TEL_NBR VALUE=\"2532668 900\">
<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(s trWriter);

writer.WriteAtt ributeString("s ession_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!P LEASEtkachenko. com> wrote in message
news:e3******** ******@TK2MSFTN GP10.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(s trWriter);

writer.WriteAtt ributeString("s ession_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(s trWriter);

writer.WriteSta rtElement("SESS ION_INFO_ID");

writer.WriteSta rtElement("TEL_ NBR");

writer.WriteAtt ributeString("V ALUE=","4258009 000"

writer.WriteAtt ributeString("E XTN=","9000");

writer.WriteAtt ributeString("N AME=","Oleg Tkachenko XML MVP")

writer.WriteEnd Element();

writer.WriteEnd Element();

string input = strWriter.ToStr ing();

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:uZ******** ******@TK2MSFTN GP10.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_I D><TEL_NBR VALUE=="4258009 000" 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.WriteAtt ributeString("E XTN=","9000");
This is obviously wrong. First argument of WriteAttributeS tring is "The
local name of the attribute". Use
writer.WriteAtt ributeString("E XTN","9000");
writer.WriteEnd Element();


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!P LEASEtkachenko. com> wrote in message
news:ua******** ******@TK2MSFTN GP11.phx.gbl...
Pete wrote:
Put this in your aspx.
Here is the result:

<SESSION_INFO_I D><TEL_NBR VALUE=="4258009 000" 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?f rame=true
writer.WriteAtt ributeString("E XTN=","9000");


This is obviously wrong. First argument of WriteAttributeS tring is "The
local name of the attribute". Use
writer.WriteAtt ributeString("E XTN","9000");
writer.WriteEnd Element();


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
2513
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 likely out of the question for now. Has someone done a more efficient minidom replacement module that we can just drop in? Preferrably written in C?
0
2349
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 Methods Version: $Revision: 1.34 $ Last-Modified: $Date: 2004/09/03 09:32:50 $ Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter
8
10644
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 the same time and set different values? Thank you for suggestions!
134
7884
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 means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
2
1558
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 immediate window it return this. Anywhere where I attempt to use two apostrophes, it inserts a backslash. Even a function in one method that saves its string to a file shows that the
19
6342
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: http://www.speedtouchdsl.com/pdf\datasheet706WL-780WL.pdf Comparing the latter with other URLs in that area, it appeared that the "\" was a probable blunder for "/". However, since their web server is IIS, it appears that their server silently fixes-up this blunder, and...
2
10621
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
9115
by: Umesh | last post by:
please help. thanks.
2
2201
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 because of it. However the physical file (xml) has no backslash before the attributes. Here is the code: string strinputfile=System.Configuration.ConfigurationSettings.AppSettings; doc.Load(strinputfile);
0
3982
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 some values while leaving the other values alone. I am designing this database/table/column so maybe I could use attributes or elements/nodes, the choice is ultimately mine. The one constraint is that I have to allow for customized name/value pairs....
0
9272
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9196
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8124
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6013
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3235
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.