I want to fetch all the text inside below tag using PowerAutomate expression, How can i achieve that? Right now i am trying with below xpath expression but it is nor returning readable result.
xpath(xml(outputs('Compose_3')),'//purpose')
<purpose>
<div xmlns="http://www.w3.org/1999/xhtml">Action due to regulatory compliance.</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">These corrective action are required by European Guideline 94/9/EG, 1999/92/EG (ATEX) and their implementation in German law BetrSichV and TRBS.</div>
<div xmlns="http://www.w3.org/1999/xhtml">Based on Risk analysis (Explosion protection </div>
</purpose>
Firstly, what you've done is obtained the values within but it's encoded as base64, you can avoid that though. Therefore, I've got two approaches for you.
All Text Extract
This is the flow ...
Initialize XML
This is merely your XML in a string variable so I can get the answer you need.
Initialize Inner Text
This expression will give you all of the inner text contained within the
purposeelement.This is the result ...
Array of Texts
This is the more complicated approach but what it does is split out the text strings into an array variable so you're able to control it better if need be.
This is the flow ...
Initialize XML
This is merely your XML in a string variable so I can get the answer you need.
Initialize Purpose Children
This is an xml/xpath expression to get an array of all
divelements within thepurposeelement.The expression with that step is ...
Initialize Inner Text Array
This is just a blank array that will be populated within the subsequent
Apply to Each.Apply To Each (Purpose Elements)
You want to loop through all of the items within the
Purpose Childrenarray.The only action occurring within there is to append to the
Inner Text Arrayvariable.The expression within that step is ...
This is the end result ...
This approach also allows you to concatenate the strings together to produce a more legitimate paragraph of text.