| Author | Message | 
		
		  | Laaziya | 
			  
				|  Posted: Tue Mar 11, 2014 6:03 am    Post subject: Need to replace some value in XML |   |  | 
		
		  | Novice
 
 
 Joined: 05 Mar 2014Posts: 13
 
 
 | 
			  
				| Hi every one, I have inserted an Xml in CLOB field. I need to retrive those Xml and  I need to replace with  some values (these values are fetched from the Table) to the Xml.
 Eg:
 <4000A>
 <2900>
 <ABC>
 <01>A</01>
 <02>B</02>
 </ABC>
 </2900>
 </4000A>
 Here  i need to replace the value of  <02></02> element. Is this possible through esql
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Tue Mar 11, 2014 7:05 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Yes it is possible. _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | sandman147 | 
			  
				|  Posted: Tue Mar 11, 2014 11:15 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 01 Sep 2013Posts: 42
 
 
 | 
			  
				| cast input as char. Declare variables to find POSITION of <2> and </2> . 
 Declare another character variable . Use substring to retrieve value between the above to positions and then finally REPLACE.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | kimbert | 
			  
				|  Posted: Tue Mar 11, 2014 1:58 pm    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 29 Jul 2003Posts: 5543
 Location: Southampton
 
 | 
			  
				| sandman147's solution might be OK if you are only changing one tag in the XML. Otherwise, the correct approach is - use CREATE...PARSE to convert your CLOB into an XMLNSC message tree ( you may need to use the ESQL CAST function to turn it into a BLOB first ).
 - Use standard message tree transformation techniques to modify the message tree. ESQL is OK. So is a Mapping node, or Java.
 - Either propagate the message tree to an output node, where it will be automatically converted to a bitstream OR use ASBITSTREAM to convert the modified message tree back to a BLOB. And CAST to turn the BLOB into a CLOB.
 _________________
 Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Tibor | 
			  
				|  Posted: Wed Mar 12, 2014 1:26 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 20 May 2001Posts: 1033
 Location: Hungary
 
 | 
			  
				| e.g. in ESQL, if your parser is XMLNSC: 
 
   
	| Code: |  
	| SET OutputRoot.XMLNSC."4000A"."2900"."ABC"."02" = 'C'; |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqceries | 
			  
				|  Posted: Tue Mar 18, 2014 8:00 am    Post subject: |   |  | 
		
		  |  Acolyte
 
 
 Joined: 02 Dec 2011Posts: 70
 
 
 | 
			  
				| Very nice and really appreciate all the replies in thread. This is one of few threads in forum..where user is not warned to check info center/ get some practical experience .. asking to do his job and all. 
 I do see the replies here are very helpful and get u started... feel free to let us know if you have any problem. A good idea always is to mention in thread if you find the solution and how it worked and all. I do missed this forum due to various issues.. but will try to follow now on.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |