Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help writing an xpath string to match multiple, but not all, table cells
    primarykey
    data
    text
    <p>Note: The question has been updated since some of the early answers were given. It's still the same question, just hopefully clearer.</p> <p>I'm trying to get a site scraper working properly and I'm having problems coming up with a suitable xpath string for some table cells.</p> <pre><code>&lt;tbody&gt; &lt;tr&gt; &lt;td class="Label" width="20%" valign="top"&gt;Uninteresting section&lt;/td&gt; &lt;td class="Data"&gt; I don't care about this&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="Data"&gt; I don't care about this&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="Label" width="20%" valign="top"&gt;Interesting section&lt;/td&gt; &lt;td class="Data"&gt; I want this-1&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="Data"&gt; I want this-2&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="Data"&gt; I want this-n&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="Label" width="20%" valign="top"&gt;Uninteresting section&lt;/td&gt; &lt;td class="Data"&gt; I don't care about this&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="Data"&gt; I don't care about this&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; </code></pre> <p>I want the contents of all the Data fields in the interesting section. There can be an arbitrary number of these. I don't care about anything else in the code, but I need all these.</p> <p>In the example above: I want this-1 I want this-2 I want this-n</p> <p>If it's relevant, I'm using xml.dom.minidom and py-dom-xpath with Python 2.7.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload