Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Input HTML File is:

PERL
<pre><html>
<body>
<h1>1.1 Heading 1</h1>
<h2>1.1.1 Heading 2</h2>
<h2>1.1.2 Heading 2</h2>
<h3>1.1.2.1 Heading 3</h3>
<h4>1.1.2.1.1 Heading 4</h4>
</body>
</html>


I am expecting Output is:

<sec id="sec1-1">
<label>1.1</label>
<title>Head 1</title>
<sec id="sec1-1-1">
<label>1.1.1</label>
<title>Head 2</title>
</sec>
<sec id="sec1-1-2">
<label>1.1.2</label>
<title>Head 2</title>
<sec id="sec1-1-2-1">
<label>1.1.2.1</label>
<title>Head 3</title>
</sec>
</sec>
</sec>


How to achieve this? Any sample or which PERL modules to get my expect output?

What I have tried:

Using PERL to close tags FILO concept using PERL Scripts
Posted
Updated 24-Nov-22 7:58am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900