2

I am using PHP Simple HTML DOM Parser. I am capturing the text between certain div tags using

$html->find(div.divname)

This works fine until the divname has a space in it.

I have tried [div name] and "div name", but, neither work. How would you work with the spaces?

Mike Dray
  • 133
  • 1
  • 1
  • 9

1 Answers1

0

I think that with $html->find(div.divname) you mean $html->find('div.divname') ...

The the divname part reflects the div's class name, not its name.

DOM element names actually may not contain spaces. Neither may their class names, as a space has a very different meaning there.

Technically you can do something like $html->find('div[name=foo bar]') for the name. Or $html->find('div[class=foo bar]') for the class name. But this will treat your attribute as literal, and will not cascade class names. So this is very bad practice and you shouldn't do it.

Community
  • 1
  • 1
nl-x
  • 11,762
  • 7
  • 33
  • 61