<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
nitin gupta wrote:
<blockquote
 cite="mid:4f59ac610910021316x6c85bdbeh399cacd003b3e35f@mail.gmail.com"
 type="cite">Thanks for your help.&nbsp;but this query will probably select
"abcfooxyz" as well when "foo" is supplied. (untested), although it
will&nbsp;definitely&nbsp;select "foo" in "foo bar" (tested)
  <div><br>
  <div>$xpath-&gt;query("//div[contains(@class, '" . $class . "')]")&nbsp;<br>
  <br>
  </div>
  <div>How can we be more specific? </div>
  </div>
</blockquote>
Try this example:
<a class="moz-txt-link-freetext" href="http://westhoffswelt.de/blog/0036_xpath_to_select_html_by_class.html">http://westhoffswelt.de/blog/0036_xpath_to_select_html_by_class.html</a><br>
<br>
<blockquote
 cite="mid:4f59ac610910021316x6c85bdbeh399cacd003b3e35f@mail.gmail.com"
 type="cite">
  <div>
  <div>@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 &nbsp;to
percentage encode the URL, because percentage encoding will make this
URL valid but will break the following URL:<br>
  <a moz-do-not-send="true" href="http://www.google.com/search?q=hello">http://www.google.com/search?q=hello</a></div>
  <div>by converting it to&nbsp;</div>
  <div><a moz-do-not-send="true"
 href="http://www.google.com/search?q%3Dhello">http://www.google.com/search?q%3Dhello</a></div>
  </div>
</blockquote>
"q=hello" is a query string, not strictly part of the path. I would
strip the url to its component parts (parse_url) and encode the path,
then re-append the query string.<br>
<br>
<a class="moz-txt-link-freetext" href="http://us2.php.net/manual/en/function.parse-url.php">http://us2.php.net/manual/en/function.parse-url.php</a><br>
<a class="moz-txt-link-freetext" href="http://www.faqs.org/rfcs/rfc1738.html">http://www.faqs.org/rfcs/rfc1738.html</a><br>
<br>
HTH,<br>
<br>
-D<br>
<br>
<br>
<blockquote
 cite="mid:4f59ac610910021316x6c85bdbeh399cacd003b3e35f@mail.gmail.com"
 type="cite">
  <div>
  <div>Looking forward.<br>
  <br>
--<br>
Regards,<br>
Nitin Kumar Gupta<br>
  <a moz-do-not-send="true" href="http://publicmind.in/blog/">http://publicmind.in/blog/</a><br>
  <br>
  <br>
On Sat, Oct 3, 2009 at 1:30 AM, Domenic Santangelo &lt;<a
 moz-do-not-send="true" href="mailto:domenic@workhabit.com">domenic@workhabit.com</a>&gt;
wrote:<br>
&gt;<br>
&gt; nitin gupta wrote:<br>
&gt;<br>
&gt; for eg &lt;div class="foo"&gt;&lt;/div&gt; is selected by the
following query.<br>
&gt; $class = "foo";<br>
&gt; $xpath-&gt;query("//*[@class = '".$class."']");<br>
&gt; But, this fails in case of multiple classes, i.e. does not select
this :<br>
&gt; &lt;div class="foo bar"&gt; &lt;/div&gt;<br>
&gt;<br>
&gt; The "contains" function would probably work, eg (untested):<br>
&gt; $xpath-&gt;query("//div[contains(@class, '" . $class . "')]");<br>
&gt;<br>
&gt; One more question: is this url valid : <a moz-do-not-send="true"
 href="http://xyz.com/path">http://xyz.com/path</a> with space.html<br>
&gt;<br>
&gt; Nope. You can escape the url if you just HAVE to have spaces:<br>
&gt;<br>
&gt; <a moz-do-not-send="true"
 href="http://n00b.com/path%20with%20space.html">http://n00b.com/path%20with%20space.html</a><br>
&gt;<br>
&gt; but why not use dashes?<br>
&gt;<br>
&gt; <a moz-do-not-send="true"
 href="http://pro.com/path-with-properly-indexed-spaces.html">http://pro.com/path-with-properly-indexed-spaces.html</a><br>
&gt;<br>
&gt; -Dom</div>
  </div>
</blockquote>
<br>
</body>
</html>