title: libxml x path expression not interpreted
body: <p>I've got the following xml text</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;projects type="array"&gt;
    &lt;project&gt;
      &lt;created-on type="date"&gt;2012-01-17&lt;/created-on&gt;
      &lt;id type="integer"&gt;8860795&lt;/id&gt;
      &lt;last-changed-on type="datetime"&gt;2012-01-17T01:37:25Z&lt;/last-changed-on&gt;
    &lt;/project&gt;
  &lt;/projects&gt;
  </code></pre>
  
  <p>So there is just one project. But I want to count the projects. In an online xpath evaluator my expression works fine and 1 is returned. But not in my libxml method. I use the following xpath expresseion:</p>
  
  <pre><code>count(/projects/project)
  </code></pre>
  
  <p>and the following objective c method for evaluation of the expression:</p>
  
  <pre><code>-(NSString*) getValueForXPathExpression:(NSString*) xPathExp_ andXMLDoc:(NSData*) xml
  {
  xmlDoc* doc = xmlParseMemory( [xml bytes], [xml length]);
  
  const unsigned char* xPathExp = (const unsigned char*) [xPathExp_cStringUsingEncoding:NSUTF8StringEncoding];
  xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
  xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression( xPathExp, xpathCtx);
  xmlNodeSetPtr nodeSetPtr = xpathObj-&gt;nodesetval;
  NSString* value;
  if( nodeSetPtr != 0 ) {
      xmlNode* node = nodeSetPtr-&gt;nodeMax &gt; 0 ? nodeSetPtr-&gt;nodeTab[0] : 0;
      if( node != 0 &amp;&amp; [[self stringFromCString:node-&gt;name] isEqualToString:@"text"] ) 
          value = [self stringFromCString:node-&gt;content];
      else
          value = [NSString stringWithFormat:@"Node for xpath Exp: %@ does not exist or is not of type text.", xPathExp_];
  } else
      value = [NSString stringWithFormat:@"nodeSetPtr for %@ is null.", xPathExp_];
  
  //XML-Parser aufräumen
  xmlFreeDoc(doc);
  xmlCleanupParser();
  
  return value;
  }
  </code></pre>
  
  <p>The return value is</p>
  
  <pre><code>nodeSetPtr for count(/projects/project) is null
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>Edit: I checked that xpathCtx and xpathObj are not null but xpathObj->nodesetval is.</p>
  
  <p>Edit2: Okay I found out. Count returns a number and not a string, therefore xpathObj->nodesetval is null but xpathObj->floatval is 1, the value I wanted. Actually quite logical since there can't be any nodeset :)</p>