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

how do I get the ampersand character back?

I'm parsing an XML file with XMLDocument, each node I write to SQL server.

Sometimes values in the XML have to contain an ampersand, so they are in the
XML as & obviously.

I assumed the .net framework took care of converting & back to &

But I'm wrong in that assumption.

For every & in the XML I receive

&

in the SQL Server data.

What am I needing to do to restore that & character?

David Bartosik
Microsoft MVP
Dec 14 '05 #1
5 4313
Hi David,

As far as I know, when you load the Xml data into the XmlDocument class,
the & will be converted to & automatically. This is the default
decoding. Will that be encoded again when data writes to SQL server? Please
check this in XmlDocument in local memory first. If that is not the case,
could you paste your code here?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 15 '05 #2


David Bartosik [MSFT MVP] wrote:
I'm parsing an XML file with XMLDocument, each node I write to SQL server. For every & in the XML I receive

&

in the SQL Server data.


What exactly are you doing to write data in the XmlDocument to the data
base?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Dec 15 '05 #3
I posted it at www.davidbartosik.com/snippet.txt
It's verbatim minus the actual xml file name.

David Bartosik
Microsoft MVP
What exactly are you doing to write data in the XmlDocument to the data
base?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Dec 15 '05 #4
I'm pretty sure I've written actual "&" to sql server before and not seen it
converted. If you didn't catch it in my post, what I find really odd is that
it's not the original & in the xml going into the sql table field, the
value is
&
My schedule the next couple of days won't afford me a chance to debug this,
thanx for telling me what to check, hopefully I can get back to it first of
the week. While I'm working on another project seemed like a good time to
multi-task this inquiry ;-)
I did post a code snippet, see my other response post.

David Bartosik
Microsoft MVP

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:U0**************@TK2MSFTNGXA02.phx.gbl...
Hi David,

As far as I know, when you load the Xml data into the XmlDocument class,
the &amp; will be converted to & automatically. This is the default
decoding. Will that be encoded again when data writes to SQL server?
Please
check this in XmlDocument in local memory first. If that is not the case,
could you paste your code here?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 15 '05 #5
Hi David,

From the code, I didn't see anything wrong. I tried it on my machine with
inserting & char into a VarChar column, it works fine. Could you show us
the insertItems stored procedure and let me know on which column did the
problem occurs? If you don't have time to debug on it currently, you can
just reply to this post whenever you have time in the future.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 17 '05 #6

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

Similar topics

3
by: Eidolon | last post by:
I am wondering how i can put an ampersand character into the value attribute of a key in the appSettings section of my web.config file. If i try to simply type it in, then run my web app, i get the...
18
by: SwordAngel | last post by:
Hello, I'm looking for a program that converts characters of different encodings (such as EUC-JP, Big5, GB-18030, etc.) into HTML ampersand escape sequences. Anybody knows where I can find one? ...
2
by: Thierry Lam | last post by:
Let's say I have the following xml tag: <para role="source">a & b</para> Currently, an xml parser will treat & as a special character. Does anyone know the special characters to use around...
2
by: RD | last post by:
Some of the customers in the table I'm trying to see in an XML doc have an ampersand in the data. Looking at them and formatting the XML doc with a style sheet this generates an error. I'm creating...
4
by: tfortney | last post by:
I created an iframe HtmlGenericControl that has an ampersand in the "src" attribute..... Dim faxFrame As New HtmlGenericControl("iframe") faxFrame.Attributes.Add("width", "100%")...
1
by: Prasanna Padmanabhan | last post by:
I want to process requests to certain image files that have a custom ..icon(32x32) extenstion with a custom .NET HttpHandler in order to be able to tap into Application events. This works fine...
1
by: klynn | last post by:
I have a web.config key as follows: <add key="DOC_TRAILER" value="&Lib=whatever&File=.pdf&Frameset=Created" /> but I cant run the app with this string. Problems with & I tried putting @ at...
9
by: keepyourstupidspam | last post by:
Hi, I am passing a string to my tokenize function, if the string contains an ampersand character only the string as far as the & character gets inputted to the function. these parameters work...
1
by: Steven Bethard | last post by:
I'm having trouble using the subprocess module on Windows when my command line includes special characters like "&" (ampersand):: .... stdout=subprocess.PIPE, .... ...
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
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...
0
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...
0
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...

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.