How to make modifications only to certain elements of an HTML string on the server-side?

You may also take a look at phpQuery.