title: How can I use the XPath count expression to evaluate a if statement?
body: <p>I'm trying to figure out how to use a Xpath expression to verify that there is only one matching node in an XPath expression.  Here is some sample XML:</p>
  
  <pre><code>&lt;a&gt;
    &lt;b&gt;
      &lt;c&gt;X:1 Y:0&lt;/c&gt;
      &lt;c&gt;X:1 Y:0&lt;/c&gt;
      &lt;c&gt;X:2 Y:0&lt;/c&gt;
    &lt;/b&gt;
    &lt;b&gt;
      &lt;c&gt;X:1 Y:0&lt;/c&gt;
      &lt;c&gt;X:2 Y:0&lt;/c&gt;
    &lt;/b&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>So, I tried code similar to this, but it doesn't work:</p>
  
  <pre><code>XPathFactory factory = XPathFactory.newInstance();
  XPath xpath = factory.newXPath();
  try {           
      XPathExpression expr = xpath.compile( "count(//a/b/c)" ) );
  } catch ( XPathExpressionException e ) {
      printErr( e );
  }
  if ( expr == true ) {
    // edit XML node
  }
  </code></pre>
  
  <p>There is supposedly a way for the count expression to return a Boolean = true .  How do I get this?</p>