How can I parse the content of each header in the below code separately.
$str="<html>
<body>
<h1>Java</h1>
<p>Java is a platform independent object oriented programming language</p>
<h2>Html</h2>
<p>HTML is a markup language for describing web documents</p>
<h3>Php</h3>
<p>Php is simple</p>
</body>
</html>";