0

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta content="text/html; charset=utf-8"><meta name="Generator" content="Amazon WorkMail v3.1.358.0"></head><body><table class="Table" width="909" style="border-collapse:collapse; width:909px"><tbody><tr><td style="background-color:#d9e1f2; border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:1px solid black; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p align="center" style="text-align:center"><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Type</span></span></span></p></td><td style="background-color:#d9e1f2; border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:1px solid black; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p align="center" style="text-align:center"><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Detail</span></span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Bot ID</span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">4122</span></span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Bot Name </span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Route U2K2 -CR </span></span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:38px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Bot Overview </span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:38px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">BOT to process all the SR's raised in remedy for Route U2K2. </span></span></span></p></td><td style="height:38px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Stakeholder/Business approver Name </span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><u><span style="color:#0563c1"><a href="mailto:Ellen.Daniel@unilever.com" style="color:#0563c1; text-decoration:underline">someemail.com</a></span></u></span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Estimated Run Costs</span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr><tr><td style="border-bottom:1px solid black; border-left:1px solid black; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:315px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif"><span style="color:black">Margin (Euros) - Optional </span></span></span></p></td><td style="border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; height:19px; padding:0cm 7px 0cm 7px; width:215px"><p><span style="font-size:11pt"><span style="font-family:&quot;Calibri&quot;,sans-serif">&nbsp;</span></span></p></td><td style="height:19px; padding:0cm 7px 0cm 7px; width:64px">&nbsp;</td></tr></tbody></table></body></html>

email body is in html converted to text like below, I need to find the required data and place those data somewhere.

How to split and take particular required text.

The logic app design : https://i.stack.imgur.com/GB3AF.png

email body image : https://i.stack.imgur.com/6k89j.png

the data was not in key value pair


Detail

Bot ID

4122

Bot Name 

Route U2K2 -CR 

Bot Overview 

BOT to process all the SR's raised in remedy for Route U2K2. 

Stakeholder/Business approver Name 


sand
  • 33
  • 1
  • 9

2 Answers2

0

This isn't really a full answer, but it may get you started.

As you can see here,, ALA supports xpath and has an xml parser built it. If you can use that, it will make everything much easier and avoid the need to convert and extract. As far as I can tell, ALA doesn't have an html parser.

The problem is that the html you posted is not a valid xml. For example, the <meta> nodes aren't closed and the whole thing doesn't have a root node. If these are fixed and you have a valid xml, using the templates in that link can easily output what you need.

For example

xpath([your valid xmlstring],'//tr/td[./p//span[./text()="Bot Name "]]/following-sibling::td/p//span[@style="color:black"]/text()')

should output:

Route U2K2 -CR 

Similarly,

xpath([your valid xmlstring],'//tr/td[./p//span[./text()="Bot Overview "]]/following-sibling::td/p//span[@style="color:black"]/text()')

should output:

BOT to process all the SR's raised in remedy for Route U2K2. 

etc. As I said, not a complete answer...

Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45
0

After converting html to text, you can use substring('<text>', <startIndex>, <length>) to get the value you want.

Before you use substring('<text>', <startIndex>, <length>), you need to get <startIndex>and <length> first.

To get startIndex

You can use indexOf(variables('var'),'Bot ID') to get the index of Bot ID, then use add(indexOf(variables('var'),'Bot ID'),6) to get the index behind Bot ID.

To get length

You can use indexOf(variables('var'),'Bot Name') to get the index of Bot Name, then use sub(indexOf(variables('var'),'Bot Name'),add(indexOf(variables('var'),'Bot ID'),6)) to get the length.

The expression like this:

substring(variables('var'),add(indexOf(variables('var'),'Bot ID'),6),sub(indexOf(variables('var'),'Bot Name'),add(indexOf(variables('var'),'Bot ID'),6)))

The design is like this:

enter image description here

I did a test:

enter image description here

Note

The text has \n to start a newline, so you need to adjust the value of the startIndex and length according to your own text.

Frank Borzage
  • 6,292
  • 1
  • 6
  • 19
  • For example, `indexOf(variables('var'),'Bot ID')`-1 means that there is no string matching `Bot ID`, please check whether the entered `Bot ID` is correct(Such as the case of characters). – Frank Borzage Oct 17 '20 at 10:06
  • Perfect Answer! substring(variables('var'),add(indexOf(variables('var'),'Bot ID'),6),sub(indexOf(variables('var'),'Bot Name'),add(indexOf(variables('var'),'Bot ID'),6))) working as per expected – sand Oct 19 '20 at 07:17
  • this is exactly working fine, problem arising to finding the very last element since we dont have next element to extract. you suugestion might help a lot. – sand Mar 16 '21 at 17:32