Is it possible to access element that contain Unicode class name?
I'm actually accessing this site, but their class name are prefixed with Unicode character U+1F41D HONEYBEE
$html = file_get_contents('https://www.honestbee.my/en/groceries/stores/bens-independent-grocer/products/720365');
$doc = new \DOMDocument();
$doc->loadHTML($html);
$xpath = new \DOMXpath($doc);
$elements = $xpath->query("//[@class='ap0']");
if (!is_null($elements)) {
foreach ($elements as $element) {
echo "<br/>[". $element->nodeName. "]";
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
Unfortunately it throws error
ErrorException : DOMXPath::query(): Invalid expression
at /paht/to/test-dom.php:83
79| $doc->loadHTML($html);
80|
81| $xpath = new \DOMXpath($doc);
82|
> 83| $elements = $xpath->query("//[@class='ap0']");
84| if (!is_null($elements)) {
85| foreach ($elements as $element) {
86| echo "<br/>[". $element->nodeName. "]";
87|
Exception trace:
1 DOMXPath::query("//[@class='ap0']")
/paht/to/test-dom.php:83
I was referring to emoji code here, tried with \uD83Dap0
also not working