Answer the question
In order to leave comments, you need to log in
PHP Simple HTML DOM Parser how to find text?
How to find an element by text between tags? For example Employment type
Tried
$html->find([text()='Employment type'])
$html->find('Employment type')
Inserted xpath ready .//*[text()='Employment type'] by which is located in Mozilla in FirePath .....
does not work (
Answer the question
In order to leave comments, you need to log in
Finally did so.
$a='';
$j=0;
while (strcmp('Employment type',$a)) {
$j++;
$a=$htm3->find('[@id=box-Details]/div[2]/div/div/dl/dt['.$j.']',0)->plaintext;
}
https://github.com/imangazaliev/didom - your code should work:
use DiDom\Document;
...
$document = new Document($html);
$elements = $documents->xpath('//*[text()="foo"]');
var_dump($elements);
I can’t talk about PHP Simple HTML DOM Parser, because I don’t use it, but I can say this about pure xpath:
normalize-space() is needed in order to avoid problems with spaces. It was this expression that worked for me on a pure xpath as it should.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question