creating an rss.xml file dynamically has issues

Discussion in 'ASP General' started by Astra, Mar 6, 2006.

  1. Astra

    Astra Guest

    Hi All

    Creating an rss.xml file dynamically via ASP/ADO/DB, but find errors in the
    file.

    Don't think it's an ASP prob to be honest. Think its more to do with the
    fact that the ampersands are accepted in the file. Do I take it that you
    have to 'escape' all non alphanumeric chars to produce a valid file?

    I thought xml files were supposed to eradicate the usual invalid char
    problems that tab-delimited and csvs used to have?

    Any ideas?

    Thanks

    Robbie
     
    Astra, Mar 6, 2006
    #1
    1. Advertising

  2. Astra

    Mike Brind Guest

    Astra wrote:
    > Hi All
    >
    > Creating an rss.xml file dynamically via ASP/ADO/DB, but find errors in the
    > file.
    >
    > Don't think it's an ASP prob to be honest. Think its more to do with the
    > fact that the ampersands are accepted in the file. Do I take it that you
    > have to 'escape' all non alphanumeric chars to produce a valid file?
    >
    > I thought xml files were supposed to eradicate the usual invalid char
    > problems that tab-delimited and csvs used to have?
    >
    > Any ideas?
    >
    > Thanks
    >
    > Robbie


    No - you don't have to escape all non-alphanumeric characters, just the
    ones that have special meaning in xml.

    Try this function for cleaning your strings up prior to outputting them
    to your rss.xml file:

    function tidyxml(text)
    text = replace(text,Chr(180),"'")
    text = replace(text,"&","&")
    text = replace(text,"'","'")
    text = replace(text,"'","'")
    text = replace(text,""","""")
    text = replace(text,""","""")
    text = replace(text,"-","-")
    text = replace(text,"<","&lt;")
    text = replace(text,">","&gt;")
    tidyxml = text
    End function

    --
    Mike Brind
     
    Mike Brind, Mar 6, 2006
    #2
    1. Advertising

  3. Astra

    Astra Guest

    Many thanks Mike

    "Mike Brind" <> wrote in message
    news:...

    Astra wrote:
    > Hi All
    >
    > Creating an rss.xml file dynamically via ASP/ADO/DB, but find errors in
    > the
    > file.
    >
    > Don't think it's an ASP prob to be honest. Think its more to do with the
    > fact that the ampersands are accepted in the file. Do I take it that you
    > have to 'escape' all non alphanumeric chars to produce a valid file?
    >
    > I thought xml files were supposed to eradicate the usual invalid char
    > problems that tab-delimited and csvs used to have?
    >
    > Any ideas?
    >
    > Thanks
    >
    > Robbie


    No - you don't have to escape all non-alphanumeric characters, just the
    ones that have special meaning in xml.

    Try this function for cleaning your strings up prior to outputting them
    to your rss.xml file:

    function tidyxml(text)
    text = replace(text,Chr(180),"'")
    text = replace(text,"&","&amp;")
    text = replace(text,"'","'")
    text = replace(text,"'","'")
    text = replace(text,""","""")
    text = replace(text,""","""")
    text = replace(text,"-","-")
    text = replace(text,"<","&lt;")
    text = replace(text,">","&gt;")
    tidyxml = text
    End function

    --
    Mike Brind
     
    Astra, Mar 6, 2006
    #3
    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. Replies:
    5
    Views:
    776
    SpaceGirl
    Feb 25, 2005
  2. Motta
    Replies:
    1
    Views:
    539
    Andy Dingley
    Jun 9, 2004
  3. Jake Barnes
    Replies:
    1
    Views:
    424
    Andy Dingley
    Nov 14, 2005
  4. Scott Gordo
    Replies:
    5
    Views:
    715
  5. Jonathan Groll
    Replies:
    1
    Views:
    281
    Kouhei Sutou
    Jun 27, 2009
Loading...

Share This Page