Dynamic xpath expression

Good afternoon, colleagues!

Please tell me how to do dynamic xpath parsing:

for example, instead of writing

$domXPath->query('//*[(@id = "article-id-18")]');

-> write something like this

$domXPath->query('//*[(@id = "article-id-*")]');

because in my case the site script generates (every time) a new id for the block containing the article text?

So the question is above.

+2


a source to share


1 answer


Try



$domXPath->query('//*[starts-with(@id, "article-id-")]');

      

+5


a source







All Articles