How to change & to & in string?

All,

I receive an xml doc with an element which contains a & in the data.  I
am attempting to insert the data into a SQL Server database and I want to
convert the & to a "&" character before I perform the insert.  Is the a
way in VB.NET to perform this?

-Rich


0
8/4/2003 12:30:05 AM
dotnet.xml 7266 articles. 0 followers. Follow

6 Replies
737 Views

Similar Articles

[PageSpeed] 14

Rich Wallace wrote:

> I receive an xml doc with an element which contains a & in the data.  I
> am attempting to insert the data into a SQL Server database and I want to
> convert the & to a "&" character before I perform the insert.  Is the a
> way in VB.NET to perform this?
I'm wondering how do you get &? I mean how do you read that data?
Anyway, here is C# code:
string str = "A&B";
string str2 = str.Replace("&", "&");
-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
8/4/2003 7:54:57 AM
Thanks Oleg,

I receive teh data when I read the XML file in by using XmlTextReader.  I'll
give your example a try and see what happens.

-Rich

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:emU5MTlWDHA.1736@TK2MSFTNGP10.phx.gbl...
> Rich Wallace wrote:
>
> > I receive an xml doc with an element which contains a &amp; in the data.
I
> > am attempting to insert the data into a SQL Server database and I want
to
> > convert the &amp; to a "&" character before I perform the insert.  Is
the a
> > way in VB.NET to perform this?
> I'm wondering how do you get &amp;? I mean how do you read that data?
> Anyway, here is C# code:
> string str = "A&amp;B";
> string str2 = str.Replace("&amp;", "&");
> -- 
> Oleg Tkachenko
> http://www.tkachenko.com/blog
> Multiconn Technologies, Israel
>


0
8/4/2003 2:02:25 PM
Now that I'm digging into it, just the string, so I guess I can chage the
way I extract the data then.

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:%23m%23guupWDHA.1748@TK2MSFTNGP12.phx.gbl...
> Rich Wallace wrote:
>
> > Yes, I'm using ReadInnerXML.
> And do you expect to read XML fragment or just string value?
> -- 
> Oleg Tkachenko
> http://www.tkachenko.com/blog
> Multiconn Technologies, Israel
>


0
8/4/2003 3:25:56 PM
Rich Wallace wrote:

> Worked great!  If I have more than one instance of the text that I want to
> replace, will it pick up all instances in the string or just the first one
> it finds?
No, it's classical substring replacement, whenever substring is matched it's 
replaced with another substring (second argument).
I'm still wondering, how do you get &amp; in XmlTextReader, probably via 
ReadInnerXml() method? Actually if you need string value (not XML fragment) as 
value you can read it using Value property or ReadElementString() method - 
then you don't have to bother about such XML-syntax-specific stuff like 
escaping & etc  - all will be done by XmlReader.

-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
8/4/2003 3:41:11 PM
Rich Wallace wrote:

> Yes, I'm using ReadInnerXML.
And do you expect to read XML fragment or just string value?
-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
8/4/2003 4:22:23 PM
you can do something like this....

reference System.Web.dll in project (if WinForm)

declare the innerXml text as a string, then

string.replace(HtmlEncode("&"), "&")




"Rich Wallace" <rich.wallace@jfshea.com> wrote in message
news:eBBtO%23hWDHA.1512@TK2MSFTNGP11.phx.gbl...
> All,
>
> I receive an xml doc with an element which contains a &amp; in the data.
I
> am attempting to insert the data into a SQL Server database and I want to
> convert the &amp; to a "&" character before I perform the insert.  Is the
a
> way in VB.NET to perform this?
>
> -Rich
>
>


0
sev (1)
8/4/2003 8:30:21 PM
Reply:

Similar Artilces:

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin´┐Żcius Pitta...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

Nokia N95 8GB & Sony Ericsson W880i ... free with Contract on Vodafone .. www.phones.shopndiscount.com
Nokia N95 8GB & Sony Ericsson W880i ... free with Contract on Vodafone .. www.phones.shopndiscount.com ...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

Removing a custom Toolbar Button & macro
I've put macro in module, then make a custom button on the toolbar to invoke a macro.(according to excel help) -------------------------------------- Create a toolbar button that runs your macro 1. On the Tools menu, click Customize, and then click the Commands tab. 2. Under Categories, click Macros. 3. Drag the custom button to the toolbar where you want it. 4. On the Customize dialog box, click Modify Selection, and then click Assign Macro. 5. In the Assign Macro dialog box, click the nam...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

Copy worksheet to new workbook : Values & Formats
Hi, Is it possible to cpy an entire worksheet (Values & Formats) to a new workbook without copying formulas ? Sheets(X).Copy is building links to previous workbook. Thks for help After coping go to Edit->Links, and break links, and excel will replace links with values. If you do it from VBA, which seems so, try with PasteSpecial metod. "Franck" <wesley.saris@gmail.com> wrote in message news:1130320762.209498.135290@g43g2000cwa.googlegroups.com... > Hi, > Is it possible to cpy an entire worksheet (Values & Formats) to a new > workbook without copying f...

How to hide Save, Save & Close button
Hi, I have created a custom entity and create a IFRAME. This IFRAME has its own save button and I am not using CRM traditional save button because of some specific requirement while saving that can only be achieve in C# coding. My problem is how to hide SAVE, SAVE and Close buttons. If I remove security with Not Write/Update permission this step hides the buttons but my _service.Create() method throws an exception becuase user don't have permission to create new record. Please help, how could I hide save/save and close or save and new buttons Regards Have a look at this blog: ...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

Running Excel 2000 & 2007 Bug
This is a multi-part message in MIME format. ------=_NextPart_000_000C_01CA53A0.C4136A80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am able to run 2000 and 2007 on the same machine ok except for the = following The File Type associations are messed up. I have a bunch of files that = were created in 2000 and they have the *.xls extension. I want these = files(when double clicked) to open in Excel 2000. However, Excel 2007 = is dominating this action. I have tried changing the association for the *.xls file type to version = 200...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

Should I change this code?
Should I change 556 to 560???..............Thanks for your help..........Bob Private Sub Command560_Click() On Error GoTo Err_Command556_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmClientInfomation" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command556_Click: Exit Sub Err_Command556_Click: MsgBox Err.Description Resume Exit_Command556_Click End Sub On Sun, 15 Jul 2007 16:37:26 +1200, "Bob V" <rjvance@ihug.co.nz> wrote: > >Should I change 556 to 560???..............Thanks for your help.....

How to change default font in Outlook 2003
Can someone tell me how to change tthe default font in Outlook 2003 when composing a new email. It always comes up as Times New Roman. I remember somewhere that I specified that Outlook should use Word as the text editor and that seems to be the case. I have Arial as my default font in Word but this seems to make no difference when using Outlook. Hi, Please go to Tools > Setting > Mail Format > Stationery and Fonts > Fonts It's right there :) On 20 Nov 2005 06:28:45 -0800, amarsarit@gmail.com wrote: >Hi, >Please go to Tools > Setting > Mail Format > Statione...

icon changes with change of extension
when we change the extension of a file in windows, its icon also changes..... how does windows do tht. in my application i require a similar approach. i want the icon to be dependent on the file extension not on the attributes of the file. i have gone trough the registry but things are not very clear. Windows has listed all the file extensions avaliable there, but there is no general way to extract icons for those extension... kindly help icon changes with change of extension "Neelu" <nemesia31@gmail.com> wrote in message news:1161232739.720722.120950@b28g2000cwb.google...

Field Type Change
I am trying to change a free text field to a drop down menu in my current database, that already has data entered for this particular field, in order to avoid multiple versions of the same organization that are just typed in differently. I'm assuming that I'll need to recode the different versions of an entry to make them uniform but after that, I'm unsure how to proceed so I won't lose any data. Is this possible or will I need to delete the field, recreate it as a drop down and then re-enter the data? Thanks in advance! Mike Thanks everyone for all the input and advice s...

Tracking Changes
I am the author of a document and am making revisions to it. I want to chnage the redline color to denote new edits from the 1st version. Can anyone guide me through this process? I am sure it is easy but I cannot figure it out. THanks Peter On Wed, 10 Feb 2010 07:08:06 -0800, Peter SSI <Peter SSI@discussions.microsoft.com> wrote: >I am the author of a document and am making revisions to it. I want to >chnage the redline color to denote new edits from the 1st version. Can >anyone guide me through this process? I am sure it is easy but I cannot >figure i...

Save Changes? #2
Sometimes, but not always, Excel asks if I want to save the current file, even though I've made no changes. Does anyone know why this occurs, and if there is a setting I can change to avoid the prompt unless actual changes are made? Thank you. Sprinks There are a number of functions that will update themselves when the workbook is opened, and this causes Excel to act as though the workbook has been changed. These functions include NOW() , TODAY(), ROW(), etc. See Volatile Functions in help for more info. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consult...

Problems with Excel 2007 flickering & locking up
I am having problems with my excel 2007. Everytime I try to work on a file the screen flickers, columns disappear, when trying to save as the program locks up and the date seems to over lap. I was not having this problem until Windows updated about 3 weeks ago. I searched the problem on the web and found some postings that said I should uninstall the update for excel. I did this but it did not solve the problem. My computer is part of a company network and is runinng Windows XP Professional version 2002 service Pack 3 and My Office Software is 2007 Professional Plus. -- kjo...

colour change of dated box
How can I change the colour of a dated box of excel after the date is over. I want the programme to read date automatically from pc and change colour. try Conditional Formatting In 2003: 1. Select the cells you want to format 2. Choose Format, Conditional Formatting 3. Choose Cell Value Is from the first drop down 3. Choose Formula is from the first drop down 4. Choose less than 5. In the third box, enter =TODAY() 6. Click the Format button 7. Choose a color on the Patterns tab (or any available option) 7. Click OK twice. -- Hope this is helpful Appreciate that you provide your feedbac...