A user will supply HTML, it may be valid or invalid (malformed). I need to be able to determine such things as:
- Is there a style tag in the body
- Is there a div that has a style attribute that makes use of width or background-image.
I have tried using the DOMDocument class but it can only do 1 and not 2 with xPath.
I have also tried simple_html_dom and that can only do 1 but not 2.
Do you think its a good idea that I just use regular expressions or is there something that I haven’t thought of?
XPath can do both (1) and (2):
To test if there’s a style tag in the body:
To test if there’s a div with a style attribute using
widthorbackground-image:And, as you were curious about in your comments, seeing if a style tag contains
a:hoverorfont-size: