Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
Extract content with Xpath and data attribute

I need to extract the content of the following div tag which has the data-visible="1" attribute and contains the div id "line".

<div class="line-name" id="line-10" data-visible="1">Need to extract</div>

I tried it like that, but I dont get any result.

$xpath->query('//*[contains(@id, "line")]//div[contains(@visible, "1")]');

What is the right way to extract the content with these both conditions and get the result:

Need to extract
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since this is a single element you should not use // after //*[contains(@id, "line")]. Also it is a data-visible attribute there, not visible.
You can use XPath expression like this:

'//div[contains(@id, "line") and @data-visible="1"]'

Or

'//div[contains(@id, "line")][@data-visible="1"]'
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda