php - Simple HTML dom css selector not working -
in reference http://simplehtmldom.sourceforge.net/
i have code:
require_once('simple_html_dom.php'); $x = '<span style="font-family:symbol">®</span>'; $dom = str_get_html($x); $lis = $dom->find('[style=~font-family:symbol]'); print_r($lis);
which tries find tags style has font-family:symbol in using css selector.
however returns nothing.
what wrong code?
please read the doc carefully... available attributes filter :
+--------------------+----------------------------------------------------------------------------------------+ | filter | description | +--------------------+----------------------------------------------------------------------------------------+ | [attribute] | matches elements have specified attribute. | | [!attribute] | matches elements don't have specified attribute. | | [attribute=value] | matches elements have specified attribute value. | | [attribute!=value] | matches elements don't have specified attribute value. | | [attribute^=value] | matches elements have specified attribute , starts value. | | [attribute$=value] | matches elements have specified attribute , ends value. | | [attribute*=value] | matches elements have specified attribute , contains value. | +--------------------+----------------------------------------------------------------------------------------+
so in case, can use last 1 example [the following tested , works]:
$lis = $dom->find('[style*="font-family:symbol"]');
Comments
Post a Comment