I’m looking to write a script in php that scans an html document and adds new markup to a element based on what it finds. More specifically, I was it to scan the document and for every element it searches for the CSS markup “float: right/left” and if it locates it, it adds align=”right/left” (based on what it finds).
Example:
<img alt="steve" src="../this/that" style="height: 12px; width: 14px; float: right"/>
becomes
<img alt="steve" src="../this/that" align="right" style="height: 12px; width: 14px; float: right"/>
edit:
When there is no certainty of amount of space between ‘float:’ & ‘right’, there are several options:
//img[starts-with(normalize-space(substring-after(@style,'float:')),'right')]//img[contains(@style,'float:'], and check with$node->getAttribute()what actually comes afterwards..