Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - XML, asp amphasand

 
Thread Tools Search this Thread
Old 07-19-2006, 04:59 PM   #1
Default XML, asp amphasand


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



jbroderick@gmail.com
  Reply With Quote
Old 07-19-2006, 05:08 PM   #2
hiredgoon
 
Posts: n/a
Default Re: XML, asp amphasand

How about converting & to &amp; ?

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

Cheers

  Reply With Quote
Old 07-19-2006, 05:17 PM   #3
hiredgoon
 
Posts: n/a
Default Re: XML, asp amphasand

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
Old 07-19-2006, 05:36 PM   #4
Andy Dingley
 
Posts: n/a
Default Re: XML, asp amphasand


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
Old 07-19-2006, 05:38 PM   #5
jbroderick@gmail.com
 
Posts: n/a
Default Re: XML, asp amphasand

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 Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump