473,811 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4340
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.mic rosoft.com> wrote in message
news:U0******** ******@TK2MSFTN GXA02.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
26577
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 following error: ---------------------------------------------------------------------------- ------------------------------------------------ Parser Error Message: This is an unexpected token. The expected token is 'SEMICOLON'. Line 70,...
18
14754
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? thx.
2
3584
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 the ampersand so that the xml parser can treat "a & b" as a whole value? Thanks Thierry
2
6708
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 the XML doc with VB.Net code, simply writing extracted values from my database to the XML doc. What do I have to do so that the ampersands in the data does not create problems while viewing the XML? Any help would b egreatly appreciated. ...
4
3729
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%") faxFrame.Attributes.Add("height", "90%") faxFrame.Attributes.Add("frameborder", "no") faxFrame.Attributes.Add("src", "/archive/view.aspx?isPlugin=" & isPlugin & "&iDoc=" & Server.UrlEncode(intDoc))
1
2887
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 almost everytime except that I get a 404 error when trying to access a file with an ampersand in its name. The error happens only if I point the aspnet_isapi.dll to the .NET Framework 1.1. If I use the aspnet_isapi.dll of the old .NET framework...
1
5918
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 beginning but that didnt fix it. What am I missing?
9
2363
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 fine name;address1;address2;addres3
1
5094
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, .... stderr=subprocess.PIPE) "'y' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" As you can see, Windows is interpreting that "&" as separating two commands, instead of being part of the single argument...
0
9728
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10402
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
9205
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...
0
6890
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
5554
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...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
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.