func (xpath *XPath) ResultAsBoolean() (val bool, err error) {
	xpath.ResultPtr = C.xmlXPathConvertBoolean(xpath.ResultPtr)
	val = xpath.ResultPtr.boolval != 0
	return
}
Coerce the result into a boolean
package xpath
import "C"
import "unsafe"
import . "github.com/moovweb/gokogiri/util"
import "runtime"
import "errors"
type XPath struct {
	ContextPtr *C.xmlXPathContext
	ResultPtr  *C.xmlXPathObject
}
type XPathObjectType int
const (
	XPATH_UNDEFINED   XPathObjectType = 0
	XPATH_NODESET                     = 1
	XPATH_BOOLEAN                     = 2
	XPATH_NUMBER                      = 3
	XPATH_STRING                      = 4
	XPATH_POINT                       = 5
	XPATH_RANGE                       = 6
	XPATH_LOCATIONSET                 = 7
	XPATH_USERS                       = 8
	XPATH_XSLT_TREE                   = 9  
)
type XPathFunction func(context VariableScope, args []interface{}) interface{}
type VariableScope interface {
	ResolveVariable(string, string) interface{}
	IsFunctionRegistered(string, string) bool
	ResolveFunction(string, string) XPathFunction
}
func NewXPath(docPtr unsafe.Pointer) (xpath *XPath) {
	if docPtr == nil {
		return
	}
	xpath = &XPath{ContextPtr: C.xmlXPathNewContext((*C.xmlDoc)(docPtr)), ResultPtr: nil}
	runtime.SetFinalizer(xpath, (*XPath).Free)
	return
}
func (xpath *XPath) RegisterNamespace(prefix, href string) bool {
	var prefixPtr unsafe.Pointer = nil
	if len(prefix) > 0 {
		prefixBytes := AppendCStringTerminator([]byte(prefix))
		prefixPtr = unsafe.Pointer(&prefixBytes[0])
	}
	var hrefPtr unsafe.Pointer = nil
	if len(href) > 0 {
		hrefBytes := AppendCStringTerminator([]byte(href))
		hrefPtr = unsafe.Pointer(&hrefBytes[0])
	}
	result := C.xmlXPathRegisterNs(xpath.ContextPtr, (*C.xmlChar)(prefixPtr), (*C.xmlChar)(hrefPtr))
	return result == 0
}
func (xpath *XPath) EvaluateAsNodeset(nodePtr unsafe.Pointer, xpathExpr *Expression) (nodes []unsafe.Pointer, err error) {
	if nodePtr == nil {
		return
	}
	err = xpath.Evaluate(nodePtr, xpathExpr)
	if err != nil {
		return
	}
	nodes, err = xpath.ResultAsNodeset()
	return
}
func (xpath *XPath) Evaluate(nodePtr unsafe.Pointer, xpathExpr *Expression) (err error) {
	if nodePtr == nil {
		return
	}
	oldXPContextDoc := xpath.ContextPtr.doc
	oldXPContextNode := xpath.ContextPtr.node
	oldXPProximityPosition := xpath.ContextPtr.proximityPosition
	oldXPContextSize := xpath.ContextPtr.contextSize
	oldXPNsNr := xpath.ContextPtr.nsNr
	oldXPNamespaces := xpath.ContextPtr.namespaces
	xpath.ContextPtr.node = (*C.xmlNode)(nodePtr)
	if xpath.ResultPtr != nil {
		C.xmlXPathFreeObject(xpath.ResultPtr)
	}
	xpath.ResultPtr = C.xmlXPathCompiledEval(xpathExpr.Ptr, xpath.ContextPtr)
	xpath.ContextPtr.doc = oldXPContextDoc
	xpath.ContextPtr.node = oldXPContextNode
	xpath.ContextPtr.proximityPosition = oldXPProximityPosition
	xpath.ContextPtr.contextSize = oldXPContextSize
	xpath.ContextPtr.nsNr = oldXPNsNr
	xpath.ContextPtr.namespaces = oldXPNamespaces
	if xpath.ResultPtr == nil {
		err = errors.New("err in evaluating xpath: " + xpathExpr.String())
		return
	}
	return
}
func (xpath *XPath) ReturnType() XPathObjectType {
	return XPathObjectType(C.getXPathObjectType(xpath.ResultPtr))
}
func (xpath *XPath) ResultAsNodeset() (nodes []unsafe.Pointer, err error) {
	if xpath.ResultPtr == nil {
		return
	}
	if xpath.ReturnType() != XPATH_NODESET {
		err = errors.New("Cannot convert XPath result to nodeset")
	}
	if nodesetPtr := xpath.ResultPtr.nodesetval; nodesetPtr != nil {
		if nodesetSize := int(nodesetPtr.nodeNr); nodesetSize > 0 {
			nodes = make([]unsafe.Pointer, nodesetSize)
			for i := 0; i < nodesetSize; i++ {
				nodes[i] = unsafe.Pointer(C.fetchNode(nodesetPtr, C.int(i)))
			}
		}
	}
	return
}
func (xpath *XPath) ResultAsString() (val string, err error) {
	if xpath.ReturnType() != XPATH_STRING {
		xpath.ResultPtr = C.xmlXPathConvertString(xpath.ResultPtr)
	}
	val = C.GoString((*C.char)(unsafe.Pointer(xpath.ResultPtr.stringval)))
	return
}
func (xpath *XPath) ResultAsNumber() (val float64, err error) {
	if xpath.ReturnType() != XPATH_NUMBER {
		xpath.ResultPtr = C.xmlXPathConvertNumber(xpath.ResultPtr)
	}
	val = float64(xpath.ResultPtr.floatval)
	return
}