title: XPath to select unique list of elements that have a certain attribute with Xpath 2.0
body: <p>I'm having a bit of trouble getting a unique list of elements (based on name) that also have a certain attribute. I can get a list of either of those, but the combined list is what's tripping me up. My xml looks like this:</p>
  
  <pre><code>&lt;global&gt;
      &lt;discipline name="tracks"&gt;
          &lt;group name="Normal"/&gt;
          &lt;group name="Gloss" PackGroup="Diffuse"/&gt;
          &lt;group name="Mask"/&gt;
          &lt;group name="Diffuse"/&gt;
          &lt;group name="Tint" PackGroup="Gloss"/&gt;
      &lt;/discipline&gt;
      &lt;discipline name="trains"&gt;
          &lt;group name="Mask"/&gt;
          &lt;group name="Diffuse" PackGroup="Mask"/&gt;
      &lt;/discipline&gt;
  &lt;/global&gt;
  </code></pre>
  
  <p>i can get a distinct list of group elements easily enough using this xpath query:</p>
  
  <pre><code>/configuration/global/discipline/group[not(@name = following::group/@name)]
  </code></pre>
  
  <p>and getting the list of group elements that have PackGroup attribute defined is trivial as well:</p>
  
  <pre><code>/configuration/global/discipline/group[@PackGroup]
  </code></pre>
  
  <p>however, i can't seem to get a unique list of elements that have PackGroup attribute defined. i've tried this:</p>
  
  <pre><code>/configuration/global/discipline/group[not(@name = following::group/@name) and @PackGroup]
  /configuration/global/discipline/group[not(@name = following::group/@name) and contains(@PackGroup, '*')]
  </code></pre>
  
  <p>which return no elements and</p>
  
  <pre><code>/configuration/global/discipline/group[not(@name = following::group/@name) and contains(@PackGroup, '')]
  </code></pre>
  
  <p>which returns just the unique list. Does anyone know what the correct xpath query is to get what i'm looking for?</p>
  
  <p>(i'm working in C# and xpath 2.0 in case that matters)</p>
  
  <p>thanks!</p>