Is it possible to get the data with DomCrawler?
$cralwer->attr('class') gets me the node's class attribute, but ->attr('data-something') or ->attr('something') always results in null.
Edit: tagging PHP also because I tried while manipulating the DomElement object from php (using ->attributes->getNamedItem()) and it still won't work. I'm wondering if it's just not possible to return a data attribute at all?
Got it. The data attribute in the source code was written as such : data-SomeAttribute.
Trying to access it with the cases ($crawler->attr('data-SomeAttribute') is what is failing here. Doing it without the case ($crawler->attr('data-someattribute') works perfectly fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With