Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7D0AFF3CFB2 for ; Tue, 8 Nov 2011 19:06:35 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 88888-10 for ; Tue, 8 Nov 2011 23:06:29 +0000 (UTC) X-Greylist: delayed 00:06:50.275057 by SQLgrey-1.8.0-rc2 Received: from mh5.mail.rice.edu (mh5.mail.rice.edu [128.42.199.32]) by mail.postgresql.org (Postfix) with ESMTP id DEED2F3CFB1 for ; Tue, 8 Nov 2011 19:06:28 -0400 (AST) Received: from mh5.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh5.mail.rice.edu (Postfix) with ESMTP id 44F63290E28 for ; Tue, 8 Nov 2011 16:59:38 -0600 (CST) Received: from mh5.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh5.mail.rice.edu (Postfix) with ESMTP id 31838290E0F for ; Tue, 8 Nov 2011 16:59:38 -0600 (CST) X-Virus-Scanned: by amavis-2.6.4 at mh5.mail.rice.edu, auth channel Received: from mh5.mail.rice.edu ([127.0.0.1]) by mh5.mail.rice.edu (mh5.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id Qy1q-DwgBOz8 for ; Tue, 8 Nov 2011 16:59:38 -0600 (CST) Received: from descarte (unknown [10.64.71.191]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (Authenticated sender: reedstrm) by mh5.mail.rice.edu (Postfix) with ESMTPSA id E8911290C0F for ; Tue, 8 Nov 2011 16:59:37 -0600 (CST) Received: by descarte (Postfix, from userid 1000) id 5B45C3C13AB; Tue, 8 Nov 2011 14:59:37 -0800 (PST) Date: Tue, 8 Nov 2011 16:59:37 -0600 From: Ross Reedstrom To: pgsql-sql@postgresql.org Subject: Re: help with xpath namespace Message-ID: <20111108225937.GA9891@rice.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/40 X-Sequence-Number: 36013 On Mon, Sep 26, 2011 at 09:56:06AM -0400, Brian Sherwood wrote: > Yep, that did it. > > Thanks! ProTip (for the list archive): since the namespace alias in the query and the original XML don't need to match (in this common case, the document uses a default namespace, which isn't available in xpaths), you can save significant typing by using a single-character namespace: select xpath(     '/j:chassis-inventory/j:chassis/j:serial-number/text()',     data_xml,     ARRAY[ARRAY['j', 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] ) from xml_test; Ross > > > 2011/9/23 Filip Rembiałkowski : > > > > > > 2011/9/22 Brian Sherwood > >> > >> select (xpath('/chassis-inventory/chassis/serial-number/text()', > >>        data_xml, > >>        ARRAY[ARRAY['junos', > >> 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] > >>       )) from xml_test; > >> > >> Can anyone suggest how I would go about getting the serial-number with > >> xpath? > >> > > > > > > http://www.postgresql.org/docs/9.1/static/functions-xml.html#FUNCTIONS-XML-PROCESSING > > - see "mydefns". > > > > This will work: > > > > select xpath( > >     '/junos:chassis-inventory/junos:chassis/junos:serial-number/text()', > >     data_xml, > >     ARRAY[ARRAY['junos', > > 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] > > ) > > from xml_test; > > > > > > > > cheers, Filip > > > > > > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >