I have analysed the given xquery and the analysis is as follows:
Fist of all, the given code lines doesn’t throw any exception. Both code lines works fine. The method getQueryContentAsString() works as :
“Gets the result of a query as a string, if available. Otherwise an empty string is returned. If the result is a set of XML nodes, the string contains the root element of each node without any children elements. Each root node is delivered with its attributes including the ino: attributes. If the result is a value or a set of values, the string returned is the concatenation of these values. In the special case, where the query results in a single value(e.g. count(*)), the string returned represents this value.”
If you want the returned value of the count function, then first retrieve the TXMLObject from TResponse. After getting TXMLObject, obtain the element using getElement() method. Then you can parse this element to get the required value.