Simple way to load xml into table

Started by Emi Luover 10 years ago3 messagesgeneral
Jump to latest
#1Emi Lu
emilu@encs.concordia.ca

Hello,

For psql 8.3, is there a simple way to load xml file into table please?

E.g.,

<rec>
<c1>True</c1>
<c2>test1</c2>
<c3>e1</c3>
</rec>
<rec>
<c1>false</c1>
<c2>test2</c2>
</rec>

Results:
t1 (c1 text, c2 text, c3 text):

c1 | c2 | c3
-----------------------------
true | test1 | e1
false | test2 | null
......

Thanks a lot!

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Rob Sargent
robjsargent@gmail.com
In reply to: Emi Lu (#1)
Re: Simple way to load xml into table

On 10/15/2015 11:38 AM, Emi wrote:

Hello,

For psql 8.3, is there a simple way to load xml file into table please?

E.g.,

<rec>
<c1>True</c1>
<c2>test1</c2>
<c3>e1</c3>
</rec>
<rec>
<c1>false</c1>
<c2>test2</c2>
</rec>

Results:
t1 (c1 text, c2 text, c3 text):

c1 | c2 | c3
-----------------------------
true | test1 | e1
false | test2 | null
......

Thanks a lot!

Shame on Concordia! 8.3. Really? (Send this up the chain)

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Emi Lu (#1)
Re: Simple way to load xml into table

On Thu, Oct 15, 2015 at 1:38 PM, Emi <emilu@encs.concordia.ca> wrote:

Hello,

For psql 8.3, is there a simple way to load xml file into table please?

E.g.,

<rec>
<c1>True</c1>
<c2>test1</c2>
<c3>e1</c3>
</rec>
<rec>
<c1>false</c1>
<c2>test2</c2>
</rec>

Results:
t1 (c1 text, c2 text, c3 text):

c1 | c2 | c3
-----------------------------
true | test1 | e1
false | test2 | null
......

Thanks a lot!

​For "simple" I don't see anything built-it better than xpath_table(...) in
the xml2 contrib module.

http://www.postgresql.org/docs/8.3/static/xml2.html

​This applies to any release since the standard SQL/XML stuff that we
implemented in 8.3+ doesn't appear to cover this particular capability​.

David J.