To remove the unknown attributes

Mar 6, 2013 at 6:33 AM
How can i remove all the attributes other than some specific attributes.

Eg: i have tags say <div><p> and <img>
<div> and <p> tag can have the following attributes
    1)id
    2)styleName
    3)typeName
and <img> can have the follwoing
                 1)source
                 2)alt
                 3)id
                 4)typeName
                 5)styleName
How can i remove if there are any other attributes?