Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>*</code> matches element nodes and not text nodes. Try replacing <code>*</code> with <code>node()</code> to select all node types.</p> <p>To break down what your XPath is doing:</p> <p>You are looking anywhere in the document (<code>//</code>) for a div with class 'contentDealDescriptionFacts cf'. </p> <p>Then you are looking for the 2nd div under that which also has the class <code>viewHalfWidthSize</code>. Note, this is not the 2nd div that has the class but the div that is 2nd AND has that class, so if the divs with that class are the 3rd and 4th it wouldn't match anything as the 2nd div with the class has <code>position() = 4</code>. If you want the 2nd <code>viewHalfWidthSize</code> div then you'll want <code>[@class='viewHalfWidthSize'][position()=2]</code>.</p> <p>Finally, you are returning a nodelist of all elements without the class <code>subHeadline</code>. If you change the <code>*</code> to <code>node()</code> then you will get a nodelist of all nodes.</p> <hr> <p>The following XPath:</p> <pre><code>//div[@class='contentDealDescriptionFacts cf']/div[@class='viewHalfWidthSize' and position()=2]/node()[not(name(.)='div' and position() = 1)] </code></pre> <p>should return what you want as long as the first child node is the div you want to ignore.</p> <p>If you change it to:</p> <pre><code>//div[@class='contentDealDescriptionFacts cf']/div[@class='viewHalfWidthSize' and position()=2]/node()[position() != count(../div[1]/preceding-sibling::node()) + 1] </code></pre> <p>then it should work regardless. It returns your nodelist, then works out how many preceding nodes there are before the first div, and checks the position isn't one greater than that (i.e. position of first div) and excludes that from the list.</p> <hr> <p>As yet another alternative you could just modify your original solution but instead of doing <code>not(@class='subHeadline')</code> you should do </p> <pre><code>not(contains(concat(' ', @class, ' '), ' subHeadline ')) </code></pre> <p>which will check if the class attribute contains <code>subHeadline</code> anywhere in the string on the assumption that your classes are space separated. This would then match your fragment which has the class <code>"subHeadline firefinder-match"</code></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.
    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