[development] Xpath query for class matching

Domenic Santangelo domenic at workhabit.com
Fri Oct 2 20:00:29 UTC 2009

nitin gupta wrote:
> for eg <div class="foo"></div> is selected by the following query.
> $class = "foo";
> $xpath->query("//*[@class = '".$class."']");
> But, this fails in case of multiple classes, i.e. does not select this :
> <div class="foo bar"> </div>
The "contains" function would probably work, eg (untested):
$xpath->query("//div[contains(@class, '" . $class . "')]");

> One more question: is this url valid : http://xyz.com/path with space.html
Nope. You can escape the url if you just HAVE to have spaces:


but why not use dashes?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20091002/31b596cd/attachment-0001.htm>

More information about the development mailing list