Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
Getting a data-attribute with DomCrawler

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?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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!

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda