To extract <P> tags in a custom manner from below mentioned input.

Following is input:

<P
align="justify"
><FONT size="+1" color="#221E1F">the tiny bundles of hairs that protrude from them. Waves in the uid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural im<FONT size="+1" color="#221E1F">pulses that are sent to the brain (Hudspeth, 2000). </P
><P
align="justify"
>These signals are routed through the thalamus to the auditory cortex, which is located mostly in the temporal lobes of the brain. Studies demonstrate that the auditory cortex has specialized cells�similar to the feature detectors found in the visual cortex�that have special sensitivity to certain features of sound (Pickles, 198. Evidence also suggests that the parallel processing of input seen in the visual system also occurs in the auditory pathways (Rouiller, 1997). </P
><DIV class="Part"

><DIV class="Sect"

><H4
align="justify"
><FONT size="+1" color="#8E2E33"><B>Auditory Perception: Theories of Hearing </H4
><P

><FONT size="+1" color="#007AA4">Figure 4.50 <FONT size="+1">The basilar membrane.<FONT size="+1" color="#221E1F"> This graphic shows how the cochlea might look if it were un<FONT size="+1"><B>wound and cut open to reveal the basilar membrane, which is covered with thousands of hair cells (the auditory receptors). Pressure waves in the uid lling the cochlea cause oscillations to travel in waves down the basilar membrane, stimulating the hair cells to re. Although the entire membrane vibrates, as predicted by frequency theory, the point along the membrane where the wave peaks depends on the frequency of the sound stimulus, as suggested by place theory. </P
><IMG align="" width="339" height="240"
src="The UNIX and Linux Forums - Free Tech Support" ></DIV
></DIV
></DIV
>

My output requirements are:

  1. To strip all attributes within <P> tags keeping <B> and <I> tag within data.
  2. Delete all attribute within H4 tags and replace resulting <H4> tag with <P> tag.
  3. Delete outer <Div> tags surrounding <P> tags.

So my OUTPUT will be:

<P>the tiny bundles of hairs that protrude from them. Waves in the uid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural impulses that are sent to the brain (Hudspeth, 2000).</P>
<P>These signals are routed through the thalamus to the auditory cortex, which is located mostly in the temporal lobes of the brain. Studies demonstrate that the auditory cortex has specialized cells�similar to the feature detectors found in the visual cortex�that have special sensitivity to certain features of sound (Pickles, 198. Evidence also suggests that the parallel processing of input seen in the visual system also occurs in the auditory pathways (Rouiller, 1997).</P>
<P>This graphic shows how the cochlea might look if it were un<FONT size="+1"><B>wound and cut open to reveal the basilar membrane, which is covered with thousands of hair cells (the auditory receptors). Pressure waves in the uid lling the cochlea cause oscillations to travel in waves down the basilar membrane, stimulating the hair cells to re. Although the entire membrane vibrates, as predicted by frequency theory, the point along the membrane where the wave peaks depends on the frequency of the sound stimulus, as suggested by place theory.</P>
<IMG align="" width="339" height="240" src="The UNIX and Linux Forums - Free Tech Support" >

Friends, this is really important for me and i'll be more than helpful if yo can help me achieving above output. Thanks a Ton!!!

Use JAVA or some other high level language. PERL/PYTHON/etc. might be a choice. You can then archive your goal easily.
You might want to read about XSLT as well - seems to be the best option.
Do not use shell/awk/etc. scripts - this would be a suicide (I have seen dozens of such attemps - all are still in use but are unmaintainable).

Not exatally what you want but might get you started.

This will remove html tags.

 sed -e :a -e 's/<[^>]*>//g;/</N;//ba' myfile