web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / create array from HTML...
Power Automate
Unanswered

create array from HTML body or from HTML to Text body

(0) ShareShare
ReportReport
Posted on by 727 Super User 2025 Season 2
Hello -
 
In my flow I am attempting to create an array of tasks from either the HTML body input or from the HTML to Text body input. See the inputs below.
I've tried slicing and splitting to no avail and I don't know which input would be easier to use.
 
The array should contain:
 
This is task 1
This is task 2
This is task 3
 
Appreciate the help!
 
Inputs:

"body": "This is task 1\n\nThis is task 2\n\nThis is task 3\n\nOther notes on the page 1.\n\nMore notes on the page 2.\n\nAgenda for today 2/5/2025\n\n-have a meeting with the team"
 
or
 
(the post kept failing if I pasted the html - so picture instead ...)
 
Categories:
I have the same question (0)
  • bscarlavai33 Profile Picture
    738 Super User 2025 Season 2 on at
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    Thanks for the reply @bscarlavai33
     
    I've seen that article and others. There are definitely clues and I'll keep trying. 
    The article refers to HTML tables and there is no table in the HTML that I need to parse so I'm still lost on it.
    Maybe I can split on the <p data-tag.
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    Use "Insert Code Snippet" to add HTML to the post.
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    test
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    Hello @Chriddle -
     
    Thanks for looking at this one. This is my fifth or sixth attempt at posting a reply. Every time I do it with code snippets either with HTML or with JSON it fails. This community is awesome, but the platform is so, so buggy.

    This time I'm including two snippets in an attached document.
    First is the HTML body. Second is after a split on the P tag in that HTML.
     
    Appreciate any assistance to get the tasks into an array out of either.
     
    Thanks!
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    hi @Chriddle -
     
    I'm noodling and I got it down to this by filtering array.
    Not sure why the last item comes with all the extras.
     
    Now, to get to the tasks from this?
     
    {
        "body": [
            " data-tag=\"to-do\" style=\"font-size:20pt;margin-top:0pt;margin-bottom:0pt\">This is task 1</p>\r\n\t\t\t",
            " data-tag=\"to-do\" style=\"font-size:20pt;margin-top:0pt;margin-bottom:0pt\">This is task 2</p>\r\n\t\t\t",
            " data-tag=\"to-do\" style=\"font-size:20pt;margin-top:0pt;margin-bottom:0pt\">This is task 3</p>\r\n\t\t</div>\r\n\t\t<div style=\"position:absolute;left:72px;top:403px;width:624px\">\r\n\t\t\t"
        ]
    }
  • Verified answer
    Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    Since your HTML is convertible to XML, just use xpath to retrieve the tasks:
     
    xpath(
    	xml(outputs('Compose_-_Email')['body']),
    	'//p[@data-tag="to-do"]/text()'
    )
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    hello @Chriddle -
     
    Thank you so much. This worked for the flow. It is so much cleaner than what I was doing.
    I'll mark the post Answered.
     
    Is there a beginner reference for using xpath and xml that I can review?
    I don't know what this is doing.
    Any chance you can read/write this back in natural language after the outputs part?
    xpath(
    xml(outputs('Compose_-_Email')['body']),
    '//p[@data-tag="to-do"]/text()'
    )
     
    I also want to put in a flow condition that checks for the <title> = 'Page with To Do' in this sample case which you can see in the header of the HTML.
    Xpath for that?
     
    Thanks!
     
  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at
    To get the title, use this:
    xpath(
    	xml(outputs('Compose_-_Email')['body']),
    	'string(//title)'
    )
     
    XPath is not that hard to learn ;)
     
    My function below does the following:
    xpath(
    	xml(outputs('Compose_-_Email')['body']), //Convert the string from the body to XML
    	'//p[@data-tag="to-do"]/text()' //Get all "p" nodes with attribute name "data-tag" and value "to-do" and return their text nodes as an array
    )
     
  • Cgangweg01 Profile Picture
    727 Super User 2025 Season 2 on at
    test

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard