X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4829B3A5E6F for ; Wed, 12 Jan 2005 23:54:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98475-09 for ; Wed, 12 Jan 2005 23:54:42 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id B328C3A5E39 for ; Wed, 12 Jan 2005 23:54:44 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CosJX-0004EV-00; Thu, 13 Jan 2005 12:54:11 +1300 Message-ID: <41E5B8A0.3030902@opencloud.com> Date: Thu, 13 Jan 2005 12:54:08 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Schuhmacher, Bret" Cc: pgsql-jdbc@postgresql.org Subject: Re: Ampersands in the output... References: <98E4F4D46DACD0479C96D7356D5C37356B031C@sac1exch3.aspect.com> In-Reply-To: <98E4F4D46DACD0479C96D7356D5C37356B031C@sac1exch3.aspect.com> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/96 X-Sequence-Number: 11976 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" (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