How to read html tag values using expressions on Azure Logic app?

Vivek Komarla Bhaskar 956 Reputation points
2023-07-12T13:15:31.02+00:00

Hi,

As part of my HTTP action, I have a JSON output that I am trying to convert to a CSV output by using a CSV data operation action. In JSON, I am reading HTML values from one of the properties. From this HTML value, I only want to take the information I need. Basically, I want to know how to read the value between every tag in this HTML value with logic app expressions.

I don't find any expressions for HTML.

FYR, below are a few sample values of the HTML property I'm reading from JSON HTTP action output:

<p>It has been claimed. </p><p>Occasinally</p><listicle id="listicle-2662266631"></listicle>

<p>A family-run business has been taking on some of the world's biggest companies by providing the “healthiest” dog food around in a David versus Goliath story. </p><p><a href="https://salterspetfood.com/" target="_blank"><strong>Salters Pet Nutrition</strong></a> rose from centuries of experience as a Suffolk butchers and is now sending its premium goods around the planet. </p><listicle id="listicle-2662266457"></listicle>


My expected results should only include text between <p>....</p> as below:

It has been claimed. Occasionally

A family-run business has been taking on some of the world's biggest companies by providing the “healthiest” dog food around in a David versus Goliath story. Salters Pet Nutrition rose from centuries of experience as a Suffolk butchers and is now sending its premium goods around the planet.
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. Sonny Gillissen 3,751 Reputation points Volunteer Moderator
    2023-07-12T20:55:49.9366667+00:00

    Hi Vivek Komarla Bhaskar

    Thank you for reaching out on Microsoft Q&A!

    I’ve tested the solution, based on your comments, in my test lab. It is possible to select all text values of the <p></p> tags using Xpath, which can be utilised through the code below:

    join(xpath(xml(concat('<html>',string(item()['body']),'</html>')),'.//p/text()'),variables('joinDelimiter'))

    User's image

    For this I made use of a variable called 'joinDelimiter':

    User's image

    In my case is I've used a return, but off course it can be anything you want, like for example a | pipe or whatever you want to use to join all <p></p> values together in a single string.

    Please click “Accept answer” if you find this helpful. Feel free to drop additional queries in the comments below!

    Please click “Accept answer” if you find this helpful. Feel free to drop additional queries in the comments below!

    Kind regards,

    Kind regards,

    Sonny

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.