0

I have some HTML ordered/ unordered list in HTML. As I want to export it to a txt file, I need to convert it to plain text.

eg. Original HTML:

<ol><li>Item 1</li></li>Item 2</li><li>Item 3</li></ol>

I want to change it to

1. Item 1
2. Item 2
3. Item 3

I searched on StackOverflow but only found a solution of the opposite conversion. A regex that converts text lists to html in PHP

Is there any ways I can handle it? Thanks!

user2335065
  • 2,337
  • 3
  • 31
  • 54
  • By the way, there is an error in the original HTML, the second li tag starts with , instead of
  • .
  • – Tim Oct 03 '19 at 09:45
  • You want HTML rendered output to be saved in a text file? – nice_dev Oct 03 '19 at 09:48
  • Do you want to know how to convert HTML to text using PHP? Or will any way be acceptable? Perhaps XSLT could be appropriate? – Abra Oct 03 '19 at 09:51