hi,
my problems is a bit case specific ,
first of all,
Its only for <p>tags not for any other tag.So you need not worry about any other tag.
I am having html document which is a output of one software  ,but it has some errors like unclosed <p> tags.
eg. I have taken all document in a string
my document is like ..
    <html>
    ....
    ....
      <head>
      </head>
    ....
    ....
       <body>
    ...
    ...
    <p>                 // tag is to be removed as no closing tag
<p align="left">   AAA   </p>
<p class="style6">   BBB    </P>
<p class="style1" align="center">    CCC    </P>
<p align="left">  DDD               // tag is to be removed as no closing tag
<p class="style6">   EEE              // tag is to be removed as no closing tag
<p class="style1" align="center">    FFF             // tag is to be removed as no closing tag
<p class="style15"><strong>xxyyzz</strong><br/></p>
<p>                // tag is to be removed as no closing tag
<p> stack Overflow </P>
       <body>
      </html>
tags with DDD,EEE,FFF and unclosed <p> tag are to be removed 
As you can see it should work for every unclosed <P> tag whether it is having attributes like class or align.
I also want to mention that, there is no <p> tag inside another <p> tag ,i mean
<p>
    <p>
    </p>
     <p>
     </p>
</p>
Such condition will never occur .
I tried using REGEX and StringBuilder but could not get perfect answer.
Thanx a lot in advance for those who will help.
Regards