Help with namespaces in xpath (PostgreSQL 9.5.3)

Поиск
Список
Период
Сортировка
От Allan Kamau
Тема Help with namespaces in xpath (PostgreSQL 9.5.3)
Дата
Msg-id CAF3N6oS+EB78LNS0eEpX29WSHiG_nCv77uHPuKtRNqDwruMNMA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Help with namespaces in xpath (PostgreSQL 9.5.3)  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
I have an xml document from which I would like to extract the contents of several elements.

I would like to use xpath to extract the contents of "name" from the xml document shown below.

WITH x AS
(
SELECT
'<?xml version="1.0" encoding="UTF-8"?>
<uniprot xmlns="http://uniprot.org/uniprot" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://uniprot.org/uniprot http://www.uniprot.org/support/docs/uniprot.xsd">
<entry dataset="Swiss-Prot" created="2009-12-15" modified="2016-05-11" version="56">
<accession>A0JM59</accession>
<name>UBP20_XENTR</name>
</entry>
</uniprot>
'::xml AS d
)
SELECT (xpath('/uniprot/entry/name/text()',a.d))[1]::text AS uniprot_name
FROM
x AS a
;



The documentation for xpath() ("https://www.postgresql.org/docs/9.5/static/functions-xml.html") describes "xpath(xpath, xml [, nsarray]").

For the above xml document, what would be the two dimensional array "nsarray" for the xpath() function?

-Allan.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tim Smith
Дата:
Сообщение: Help needed structuring Postgresql correlation query
Следующее
От: Johan Thomsen
Дата:
Сообщение: pg_dump from a hot standby replication slave