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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

create array from HTML body or from HTML to Text body

(0) ShareShare
ReportReport
Posted on by 870 Super User 2026 Season 1
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
    752 Super User 2026 Season 1 on at
  • Cgangweg01 Profile Picture
    870 Super User 2026 Season 1 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,672 Super User 2026 Season 1 on at
    Use "Insert Code Snippet" to add HTML to the post.
  • Cgangweg01 Profile Picture
    870 Super User 2026 Season 1 on at
    test
  • Cgangweg01 Profile Picture
    870 Super User 2026 Season 1 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
    870 Super User 2026 Season 1 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,672 Super User 2026 Season 1 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
    870 Super User 2026 Season 1 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,672 Super User 2026 Season 1 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
    870 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard