| Author | Message | 
		
		  | aoff | 
			  
				|  Posted: Wed Jun 17, 2015 9:36 am    Post subject: Converting XML to Text - ESQL |   |  | 
		
		  | Newbie
 
 
 Joined: 17 Jun 2015Posts: 3
 
 
 | 
			  
				| Hello guys, 
 I'm facing some troubles trying to convert a XML message to a text format. Here's what I'm trying.
 
 I have de following message as example:
 
 
 
   
	| Code: |  
	| <?xml version="1.0" encoding="UTF-8"?> <credit_limits credit_limit_number="999" processing_date="16052014-08:00:00" status="01" error_msg="9999">
 <credit_limit>
 <cnpj_agent>99.999.999/0001-99</cnpj_agent>
 <agent_name>AAAAAAAAAAAAAA</agent_name>
 <action_type>01</action_type>
 <first_liquidation_date>16052014</first_liquidation_date>
 <status>01</status>
 <inconsistence_type>01</inconsistence_type>
 <code_error>9999</code_error>
 </credit_limit>
 </credit_limits>
 |  
 I need to set every line into a list of string[1..*] like:
 
 My first line of the XML is <?xml version="1.0" encoding="UTF-8"?> so the first element of the list will be "<?xml version="1.0" encoding="UTF-8"?>".
 
 I have 13 lines considering that a line ends with a ">", so the list will contain 13 elements.
 
 I'm trying to use ASBISTREAM Function to convert the XMLNSC to a BLOB, them convert the BLOB to a CHAR, but is not working.
 
 Does anyone knows a better way to do this?
 
 Thanks a lot!
  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nelson | 
			  
				|  Posted: Wed Jun 17, 2015 9:40 am    Post subject: |   |  | 
		
		  |  Partisan
 
 
 Joined: 02 Oct 2012Posts: 313
 
 
 | 
			  
				| What will be your serialized output? why do you need to split your XML in that way? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Wed Jun 17, 2015 9:50 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| Why do you need to pretty-print the XML document? 
 If some other parser reads it again, it will end up including mixed-content (the line endings).
 
 This is probably not ideal.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aoff | 
			  
				|  Posted: Wed Jun 17, 2015 10:09 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 17 Jun 2015Posts: 3
 
 
 | 
			  
				| I need to do this because I'll request a service that will encrypt the list line by line and return me a list of Base64 data type. I do not agree with this, but i have to follow orders   
 Basically what I need to do is put line by line of the XML into position by positon of a string list.
 
 I thougth that would be simple convert all the XML message into CHAR then split line by line using a Substring function with CRLF as parameter.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Wed Jun 17, 2015 10:19 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| You can do the SUBSTITUTE on the blob itself. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | aoff | 
			  
				|  Posted: Wed Jun 17, 2015 11:02 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 17 Jun 2015Posts: 3
 
 
 | 
			  
				| 
   
	| mqjeff wrote: |  
	| You can do the SUBSTITUTE on the blob itself. |  
 What do you mean with SUBSTITUTE?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Wed Jun 17, 2015 11:03 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| 
   
	| aoff wrote: |  
	| 
   
	| mqjeff wrote: |  
	| You can do the SUBSTITUTE on the blob itself. |  
 What do you mean with SUBSTITUTE?
 |  
 a typo.  Substring/etc.  There's a replace or something?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | inMo | 
			  
				|  Posted: Wed Jun 17, 2015 12:07 pm    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Jun 2009Posts: 216
 Location: NY
 
 | 
			  
				| Please see below for solution from fjb_saper. 
 Last edited by inMo on Wed Jun 17, 2015 12:23 pm; edited 2 times in total
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | inMo | 
			  
				|  Posted: Wed Jun 17, 2015 12:13 pm    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 27 Jun 2009Posts: 216
 Location: NY
 
 | 
			  
				| 
   
	| aoff wrote: |  
	| I need to do this because I'll request a service that will encrypt the list line by line and return me a list of Base64 data type. I do not agree with this, but i have to follow orders   
 |  
 Just curious
 
 1. What do a bunch of encrypted lines buy that a single encrypted line does not?
 2. Is the encryption actually base64 or is base64 applied against an actually  encrypted string?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | fjb_saper | 
			  
				|  Posted: Wed Jun 17, 2015 12:15 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| Simpler.... Replace all "><" with ">{CRLF}<" You'll be missing the correct indentation for the pretty print but the result should have every line ...
  _________________
 MQ & Broker admin
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |