5

PostgreSQL Version 9.1,

i have a table,

xmltest=# \d xmltest
    Table "public.xmltest"
 Column  |  Type   | Modifiers 
---------+---------+-----------
 id      | integer | not null
 xmldata | xml     | 
Indexes:
    "xmltest_pkey" PRIMARY KEY, btree (id)

xmltest=# select * from xmltest;
 id |                xmldata                
----+---------------------------------------
  1 | <root>                               +
    | <child1>somedata for child1 </child1>+
    | <child2>somedata for child2 </child2>+
    | </root> 
(1 row)

now how to update the value inside the element/tag child2,

i don't prefer to update the whole column at once,

is their a way to do update/add/delete that particular value of tag, if so please share :)

1 Answer 1

3

PostgreSQL XML functions are aimed a producing and processing XML, not so much at manipulating it, I am afraid.

You can extract values with xpath(), there are a number of functions to build XML, but I would not know of built-in functionality to update elements inside a given XML value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.