title: Boolean operation in Xpath: Using attributes
body: <p>Following is a snippet of .xml file. I did following :</p>
  
  <pre><code>Document doc = docBuilder.parse(filesInDirectory.get(i));
  doc.getDocumentElement().normalize();
  XPath xPath = XPathFactory.newInstance().newXPath();
  XPathExpression expr1 = xPath.compile("//codes[@ class ='class2']/code[@code]");
  Object result1 = expr1.evaluate(doc, XPathConstants.NODESET);
  NodeList nodes1 = (NodeList) result1;   
  </code></pre>
  
  <p>Now,</p>
  
  <pre><code>System.out.println("result length"+":"+nodes1.getLength());
  returns 2.
  </code></pre>
  
  <p>I would like to make logical decision based on the attribute names, like(pseudocode) </p>
  
  <pre><code> if(nodes1.contains(123))
  </code></pre>
  
  <p>or</p>
  
  <pre><code>if(nodes1.contains(123) &amp;&amp; nodes1.contains(456))
     and make decision.
  </code></pre>
  
  <p>how would i do it?</p>
  
  <pre><code>&lt;metadata&gt;
     &lt;codes class="class1"&gt;
       &lt;code code="ABC"&gt;
           &lt;detail "blah" "blah"&gt;
       &lt;/code&gt;
    &lt;/codes&gt;
    &lt;codes class="class2"&gt;
      &lt;code code="123"&gt;
          &lt;detail "blah blah"/&gt;
      &lt;/code&gt;
      &lt;code code="456"&gt;
          &lt;detail "blah blah"/&gt;
      &lt;/code&gt;
    &lt;/codes&gt;
   &lt;/metadata&gt;
  </code></pre>