2

Good day, colleagues!

Tell me please, how to make a dynamic xpath-parsing:

for example, instead of writing

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

-> write something like that

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

, because in my case, the site's script generate (every time) a new id for block, that contains article's text?

So question, is above.

YOU
  • 120,166
  • 34
  • 186
  • 219
Ferol
  • 21
  • 2

1 Answers1

5

Try

$domXPath->query('//*[starts-with(@id, "article-id-")]');
YOU
  • 120,166
  • 34
  • 186
  • 219
  • I've just tested your suggestion, and in all cases gotten only: bool(false); very strange – Ferol Apr 22 '10 at 11:25
  • I wrote: $domNodeList = $domXPath->query('//*[starts-with(@id, "article-id-")]'); echo var_dump($domNodeList); exit; – Ferol Apr 22 '10 at 11:27
  • yippee!!! now works fine!)) mega-bomb! Thanks man! It was my mistake)) ps: where I can find more information about domxpath expressions? – Ferol Apr 22 '10 at 11:34
  • Hi @Ferol, I use this one - http://www.zvon.org/xxl/XPathTutorial/General/examples.html – YOU Apr 22 '10 at 11:35