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)<div><br>
<div>$xpath->query("//div[contains(@class, '" . $class . "')]") <br><br></div><div>How can we be more specific? <br><br>@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 following URL:<br>
<a href="http://www.google.com/search?q=hello">http://www.google.com/search?q=hello</a></div><div>by converting it to </div><div><a href="http://www.google.com/search?q%3Dhello">http://www.google.com/search?q%3Dhello</a></div>
<div><br></div><div>Looking forward.<br><br>--<br>Regards,<br>Nitin Kumar Gupta<br><a href="http://publicmind.in/blog/">http://publicmind.in/blog/</a><br><br><br>On Sat, Oct 3, 2009 at 1:30 AM, Domenic Santangelo <<a href="mailto:domenic@workhabit.com">domenic@workhabit.com</a>> wrote:<br>
><br>> nitin gupta wrote:<br>><br>> for eg <div class="foo"></div> is selected by the following query.<br>> $class = "foo";<br>> $xpath->query("//*[@class = '".$class."']");<br>
> But, this fails in case of multiple classes, i.e. does not select this :<br>> <div class="foo bar"> </div><br>><br>> The "contains" function would probably work, eg (untested):<br>
> $xpath->query("//div[contains(@class, '" . $class . "')]");<br>><br>> One more question: is this url valid : <a href="http://xyz.com/path">http://xyz.com/path</a> with space.html<br>
><br>> Nope. You can escape the url if you just HAVE to have spaces:<br>><br>> <a href="http://n00b.com/path%20with%20space.html">http://n00b.com/path%20with%20space.html</a><br>><br>> but why not use dashes?<br>
><br>> <a href="http://pro.com/path-with-properly-indexed-spaces.html">http://pro.com/path-with-properly-indexed-spaces.html</a><br>><br>> -Dom<br><br></div></div>