XML, asp amphasand

J

jbroderick

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;Database=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
 
H

hiredgoon

How about converting & to &amp; ?

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

Cheers
 
A

Andy Dingley

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top