I'm trying to create an html file comparison script using PEAR Text_Diff. One problem I got is when changing an image.

For example, here
Code:
<ins><b>Stains</b></ins> and dirt must be <del>removed</del>
immediately. A hot water rug <img <del>src='rat.jpg'</del><ins>src='fox.jpg'</ins> /> cleaner
<del>.....</del> - deleted patterns
and
<ins>......</ins> - inserted patterns

But when we are changing something inside tag (in between < and >), it's getting messed up. For example, if I'm changing src of the img tag, the result will be <img <del>src='rat.jpg'</del><ins>src='fox.jpg'</ins> />

So what I'm looking for a function to pass my string and

if there is any <del> or <ins> found after '<' and before '>' of a tag, the <ins> or <del> should move to before '<'

and

if there is any </del> or </ins> found after '<' and before '>' of a tag, the </ins> or </del> should move to before '>'

Any idea?

Thanks
Habeeb