Max Frai
Max Frai

Reputation: 64266

Simple html dom parser

I use simple php dom parser. I have a link in my loaded dom which looks like this (in html):

<a href="...">Some const tesxt</a>

How can I select this object using find function? Maybe I can pass regular expression which looks at a container text? Btw, it's static(constant) text and I want to search need link refer to that text.

Upvotes: 1

Views: 745

Answers (1)

Jim
Jim

Reputation: 18853

Reading through the Manual it should give you all you need to know.

$ret = $html->find('a');

foreach ($ret as $link) {
    if ($link->innertext == 'Someconst tesxt') {
          // do what you must.
    }
}

Not sure what else you are looking for, but I am not able to test the above, just put it together from reading the manual.

Upvotes: 2

Related Questions