Re: How to change content of xml datatype

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to change content of xml datatype
Date: 2013-11-20 17:31:44
Message-ID: 528CF200.7070004@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/20/2013 10:21 AM, gajendra s v wrote:
> Hi All,
>
>
> I need to change content of xml ,Please any one suggest me how to
> do,the xml is below
>
>
> <Grading_Automated><PassOrFail>Fail</PassOrFail><ActivityScorebased><AutomatedSequence
> Value="0"/><Percentage>25</Percentage><Value>34</Value><AutomatedSequence
> Value="1"/><Percentage>99</Percentage><Value>432</Value><AutomatedSequence
> Value="2"/><Percentage>43</Percentage><Value>232</Value><AutomatedSequence
> Value="3"/><Percentage>43</Percentage><Value>323</Value><AutomatedSequence
> Value="4"/><Percentage>33</Percentage><Value>432</Value><AutomatedSequence
> Value="5"/><Percentage>45</Percentage><Value>3432</Value></ActivityScorebased></Grading_Automated>
>
> I want xml like below,is there any way
>
> '<Grading_Automated><PassOrFail>*Pass*</PassOrFail><ActivityScorebased><AutomatedSequence
> Value="0"/><Percentage>*40*</Percentage><Value>34</Value><AutomatedSequence
> Value="1"/><Percentage>99</Percentage><Value>432</Value><AutomatedSequence
> Value="2"/><Percentage>43</Percentage><Value>232</Value><AutomatedSequence
> Value="3"/><Percentage>43</Percentage><Value>323</Value><AutomatedSequence
> Value="4"/><Percentage>33</Percentage><Value>432</Value><AutomatedSequence
> Value="5"/><Percentage>45</Percentage><Value>3432</Value></ActivityScorebased></Grading_Automated>
>
If you want all '<PassOrFile>Fail' changed to '<PassOrFail>Pass' you
have straight forward replace, perhaps with a regexp if <PassOrFail> is
elsewhere in xml record. If you need to set specific values for
specific records, your looking at parsing the xml (SAX, DOM, take you
pick) and re-writing the record.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2013-11-20 19:33:05 Re: Postgres as In-Memory Database?
Previous Message gajendra s v 2013-11-20 17:21:42 How to change content of xml datatype