dbTalk Databases Forums  

xml2 on win32

comp.databases.postgresql comp.databases.postgresql


Discuss xml2 on win32 in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #41  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: xml2 on win32 - 10-31-2008 , 06:23 AM






Zeljko Peric <deckic (AT) web (DOT) de> wrote:
Quote:
However, my idea is to load whole xml document in one cell (not line by
line as COPY it does). I do not have error messages when I load document
with COPY (the function load_xml uses COPY).
I see, it's the line breaks that cause the problem.
Sorry, I didn't get that (although it was written in your original post).

The solution here would be to escape the line breaks.

For example, the following document:

<?xml version="1.0">
<something>
<other attrib="some value"/>
</something>

would be modified as such:

Quote:
?xml version="1.0"
something
<other attrib="some value"/>
</something>|

(assuming that | does not occur in the XML)

and loaded with

COPY tabname (xmlcol) FROM 'filename' CSV QUOTE '|'

That should solve your original problem.

Quote:
Once the document is loaded into database, I can start to process it
with xml path functions, and to transform it to html or something else.
In this case I'll using xml type.
For example:

CREATE TABLE test (xml_data text);

INSERT INTO test (xml_data)
select load_xml(filepath);

Process document:

select xmlroot(XMLPARSE(document xml_data), version '1.0', standalone
yes) from test
The problem here is that whenever you want to use an XML function, you
have to parse the document. That means a lot of processing overhead!
Better is to store the column as data type "xml".
That way it is parsed only once, when it is inserted.

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.