[development] Xpath query for class matching
nitingupta.iitg at gmail.com
Fri Oct 2 20:16:22 UTC 2009
Thanks for your help. but this query will probably select "abcfooxyz" as
well when "foo" is supplied. (untested), although it will definitely select
"foo" in "foo bar" (tested)
$xpath->query("//div[contains(@class, '" . $class . "')]")
How can we be more specific?
@URL: Actually I am maintaining the module feedapi imagegrabber, which
downloads images from external websites. Now sometimes the url I parse has
spaces, so I am unable to decide whether or not to percentage encode the
URL, because percentage encoding will make this URL valid but will break the
by converting it to
Nitin Kumar Gupta
On Sat, Oct 3, 2009 at 1:30 AM, Domenic Santangelo <domenic at workhabit.com>
> 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...
More information about the development