Re: Ampersands in the output...

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: "Schuhmacher, Bret" <Bret(dot)Schuhmacher(at)Aspect(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Ampersands in the output...
Date: 2005-01-12 23:54:08
Message-ID: 41E5B8A0.3030902@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Schuhmacher, Bret wrote:
> I'm using postgres to return business names via a function. In the
> function I "xml-ify" the output by taking the name and wrap it with
> start/end tags, as in "<name>name</name>" (there's a lot more to this
> and I'm simplifying greatly). However, the problem is that some of the
> names have "&" in them, like "Joes Bar & Grill", which really should be
> escaped in XML.
>
> Any ideas how to escape those things before they get to the recipient
> (i.e. my application, IE, Mozilla, etc.)? Is there a built-in function
> or something I could make use of? I suppose I could write a little more
> code in my function to look in the field and try to do a string replace
> or something, but is that the most efficient method?

This is unrelated to the JDBC driver. Please use an appropriate list.

That said, it depends very much on how you are generating your XML.
Serializing a DOM tree should do the escaping for you. A reverse SAX
parser should also do it.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Siegmar 2005-01-13 13:19:00 Problems with infinity
Previous Message Schuhmacher, Bret 2005-01-12 23:20:41 Ampersands in the output...