Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML, asp amphasand

Reply
Thread Tools

XML, asp amphasand

 
 
jbroderick@gmail.com
Guest
Posts: n/a
 
      07-19-2006
I have a .asp document on my server it goes as follows
---
<?xml version="1.0" standalone='yes'?>
<Restaurants>
<%
Dim objConn
Dim objRS

set objConn = Server.CreateObject("ADODB.Connection")
set objRS = server.CreateObject("ADODB.recordset")


objconn.open "Driver={SQL
Server};Server=localhost;Uid=user;Pwd=pass;Databas e=me"
objRS.activeconnection = objConn
objRS.open "SELECT RestaurantName, PremisesAddressLine1 as
Address
FROM tblRestaurantAccounts WHERE franchiseID= 16 and accountstatus=0"


do until objRS.eof
response.write vbtab & "<Restaurant>" & vbcrlf
response.write vbtab & vbtab & "<Shop>" &
objRS.fields("Restaurantname").value & "</Shop>" & vbcrlf
response.write vbtab & vbtab & "<Address>" &
objRS.fields("address").value & "</Address>" & vbcrlf
response.write vbtab & "</Restaurant>" & vbcrlf
objRS.movenext
loop


objRS.close
objConn.close


set objRS = nothing
set objConn = nothing
%>
</Restaurants>
---


the only problem is that it chokes when it gets a record entry that
contains a "&". what code do i need or what modifications to my code to

let this .asp document display a "well-formed" xml document?


thanks for your help


Jonathan Carl Broderick

 
Reply With Quote
 
 
 
 
hiredgoon
Guest
Posts: n/a
 
      07-19-2006
How about converting & to &amp; ?

Replace(objRS.fields("Restaurantname").value,"&",& amp;")

Cheers

 
Reply With Quote
 
 
 
 
hiredgoon
Guest
Posts: n/a
 
      07-19-2006
OOPS - i missed a "

Replace(objRS.fields("Restaurantname").value,"&"," &amp;")


hiredgoon wrote:

> How about converting & to &amp; ?
>
> Replace(objRS.fields("Restaurantname").value,"&",& amp;")
>
> Cheers


 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      07-19-2006

wrote:

> the only problem is that it chokes when it gets a record entry that
> contains a "&". what code do i need or what modifications to my code to


Look up Server.HTMLEncode() (and its colleague .URLEncode() )

Don't do it "longhand" with string replace functions.

 
Reply With Quote
 
jbroderick@gmail.com
Guest
Posts: n/a
 
      07-19-2006
Excerlent, works a treat, cheers mate

hiredgoon wrote:
> OOPS - i missed a "
>
> Replace(objRS.fields("Restaurantname").value,"&"," &amp;")


> > Cheers


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Amphasand, XML jbroderick@gmail.com ASP General 6 07-21-2006 11:53 AM
global filter to redirect asp (old asp!) pages on asp.net site Daves ASP .Net 2 05-31-2006 08:33 AM
2.0: asp:Menu, asp:XmlDataSource, asp:PlaceHolder R.A.M. ASP .Net 1 03-29-2006 07:55 AM
[ASP.NET1.1]Should I kill the ASP.NET worker process after recompilingmy ASP.NET webservice? Andrea Raimondi ASP .Net 1 02-06-2006 08:10 AM
ASP.Net cookie -> ASP -> ASP.Net Ben ASP .Net 3 05-28-2004 03:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57