[development] Xpath query for class matching

nitin gupta nitingupta.iitg at gmail.com
Fri Oct 2 19:44:07 UTC 2009

Hi all,
For the module I am maintaining at drupal, I need to select the element
which has a specific class. I am using the following query for it:

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>

I don't have much experience in writing regex, can someone please help me
out with this.

One more question: is this url valid : http://xyz.com/path with space.html

Looking forward.
Nitin Kumar Gupta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20091003/1c9496f3/attachment.htm>

More information about the development mailing list