Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tBJej-0031cA-JT for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2024 20:08:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tBJeg-00GPia-TX for pgsql-general@arkaria.postgresql.org; Wed, 13 Nov 2024 20:07:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tBJeg-00GPiS-GX for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2024 20:07:59 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tBJee-001iOi-5O for pgsql-general@lists.postgresql.org; Wed, 13 Nov 2024 20:07:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1731528474; x=1732133274; i=shammat@gmx.net; bh=QYZIEwhVETRR1RtgajkTmgxsixej9agJPVWd6KPF2j4=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=Aj9nN3nSA79v6+JyLS3gWETWP4EE4cEXUbqYJQsKTIY5TB8jWNKxIT05+ybFRRu5 pg5SY4ct+8TOk+J2ylNPXj8By9yTzDJ0VN7fZClBXX+1jygVdJW4X8vqkHP93dieS hOskFSwjV/pu31QTgi7PQCVN1RCQyHTCA2DvU1PfQEu9MFjCiGrSX0pq639nhBn2Y m22YMrnhlxKcSkfW8c5WhGFCeyxKdlByBVenmaK/Yhhc9K29PZacu+p4LMbMXwtjm icHGRJ127Z5Zl2HUUNTNpN7PB6QPQLMbuNAQ5cORQGgadNoag2NDXI8B5Bc/CZB7x w4s7k043CSa23Ts+Pg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.31] ([88.217.180.155]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MFbVu-1szovs0OSM-00GEfS for ; Wed, 13 Nov 2024 21:07:54 +0100 Message-ID: <44c41d77-8a4f-4929-9827-0c8993a88f14@gmx.net> Date: Wed, 13 Nov 2024 21:07:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Extract values from XML content To: pgsql-general@lists.postgresql.org References: Content-Language: de-DE, en-US From: shammat@gmx.net In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:y7GGCD4lQqqOjV2eZuC30CaO90Mi7W+dy/slf8xlF+s29fNpUyw 3yrRcjeJHDc2sp0250IOjMwjfyDX8PB1uAsmojSWN0gSngVFB6roEHv3ehy77Bkv4zlbPPa n5yrXZMXEY/1n4Qp8R1Hm8mucMONusTK6etWTE/b2S/zP6s6q8xcxf32hRD0/O3FMpZn4XK sRrlHPHXXNJeYl4nx+xuA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:jjZlSoETIcA=;N+oQruevvQSVDze5nOU6LqNao8N 23hN3mnzxOjvdZIzE0c7nRCMcS1X2D+vRqZXov9DRHRT3Px8efoYGvHFcwAGSQNiJBJOaKME/ /clkQmjRjnjE6Uowixn12GGo1ZSYF8KeC4EofzbGW1Zoka+ZZ2Ezg8iulMOfBp9f7cKJTxjHV RhAjQTxODLX45VU8Z/GI0QBotu6Yn+U8V153BiMWuxohaR1ZhhGGTK4UlZPgszhHvP2SXrP8h MScCfXRCGabHyQRgJZg8X+mVy1lhu0nLwppAugx8C0+PlJhYhbF8EXLfDg9oUooZ1/0IASCpa iWuWDCCAVyFExJfKedw/jSxWIG4ApGFnIFH5U2ljN1cPBvyIQKyci1sovb4i8H5JPRVwix3ty KroeTI7AdMeknuQ6Ahgt3AtS8A4KG9jhN0Wlb46sjnvx8aKobfwDG3HbwVxkIjcWd0U+Krhot bKFs+wdrU5iQVAm0MOccTT8E2fC6Oihvx66mHatrLSKTXmKE5Q/HNA11aHTgG9OhZPKExdMN/ ZfT3oT/MF6BP8aqPMoGj887TniBdDRKhzoOmNBanosyTPcnYLa3CLVbXgu85irgz3d4rVfzzv fJYX3nAjpsjAm0+NSU+4i5awG1sgeB+MzhAti7wQg0MuAN23U32M/AobwQUPHzpNcxARTw3S8 grnhZrDj0jGPObir5Z75STSJDUe9JFUozquJ5N2H/oDRC0xvtnee5FD1v0z043vY/q2b58W9E 5U9qLpnUdaZJtGdtHlBobXQVgyZBz2gISfNtiriIBYcnY8AmCPRoXgxEWaY/gpq3FDl/1hDBU SYXeoJE2AhPQWJqmH51lebQRa5y/lJx5CjMhUvaVp8Rzc3eFVGiYxC2uMvk5htlgdX1jAzKIO K3Q2Z/uf2YTjBwGwvcd3hU2Vwo7CQaKHfyzji76qdkbR6B7qLApeF8Ngz List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am 13.11.24 um 15:58 schrieb celati Laurent: > I have a table 'metadata' with 2000 records. With one column 'id' and on= e column 'data' with XML content. > I need to extract for all records the values regarding the Organisation = names. > I success in querying without error message thanks to this following sql= query : > > SELECT id, xpath('/contact/CI_ResponsibleParty/organisationName/Characte= rString/text()', > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CAST(data AS XML)) AS organis= ation_name > FROM public.metadata; > I typically find xmltable() a lot easier to work with, especially if the X= ML contains namespaces. I guess the namespaces are the problem in your case, you will have to pass= them to the xpath() function and reference them in the path expression as well So you will need something like: xpath('//cit:CI_Responsibility/cit:party/cit:CI_Organisation/cit:name/gco:= CharacterString/text()', cast(data as xml), ARRAY[ARRAY['cit', 'http://...'], array['gco', 'http://...']]) The actual value for the namespace URIs depends on the definition in your = XML Note that xpath() returns an array, so you probably want (xpath(....))[1]