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