XML, asp amphasand

Discussion in 'XML' started by jbroderick@gmail.com, Jul 19, 2006.

  1. Guest

    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
     
    , Jul 19, 2006
    #1
    1. Advertising

  2. hiredgoon Guest

    How about converting & to &amp; ?

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

    Cheers
     
    hiredgoon, Jul 19, 2006
    #2
    1. Advertising

  3. hiredgoon Guest

    OOPS - i missed a "

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


    hiredgoon wrote:

    > How about converting & to &amp; ?
    >
    > Replace(objRS.fields("Restaurantname").value,"&",&amp;")
    >
    > Cheers
     
    hiredgoon, Jul 19, 2006
    #3
  4. Andy Dingley Guest

    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.
     
    Andy Dingley, Jul 19, 2006
    #4
  5. Guest

    Excerlent, works a treat, cheers mate

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


    > > Cheers
     
    , Jul 19, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bomb Diggy
    Replies:
    0
    Views:
    469
    Bomb Diggy
    Jul 28, 2004
  2. Tony Prichard
    Replies:
    0
    Views:
    788
    Tony Prichard
    Dec 12, 2003
  3. Matt
    Replies:
    3
    Views:
    368
    Bob Barrows [MVP]
    Apr 23, 2004
  4. ASP Amphasand, XML

    , Jul 19, 2006, in forum: ASP General
    Replies:
    6
    Views:
    137
    Anthony Jones
    Jul 21, 2006
  5. Erik Wasser
    Replies:
    5
    Views:
    520
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page