Ejemplo n.º 1
0
func NewXPathExpression(s string) (*XPathExpression, error) {
	p := C.xmlXPathCompile(stringToXmlChar(s))
	if p == nil {
		return nil, errors.New("xpath compilation failed")
	}

	return &XPathExpression{ptr: p, expr: s}, nil
}
Ejemplo n.º 2
0
func Compile(path string) (expr *Expression) {
	if len(path) == 0 {
		return
	}

	xpathBytes := GetCString([]byte(path))
	xpathPtr := unsafe.Pointer(&xpathBytes[0])
	ptr := C.xmlXPathCompile((*C.xmlChar)(xpathPtr))
	if ptr == nil {
		return
	}
	expr = &Expression{Ptr: ptr, xpath: path}
	//runtime.SetFinalizer(expr, (*Expression).Free)
	return
}
Ejemplo n.º 3
0
// xmlXPathCompile
func CompileXPath(str string) *XPath {
	ptr := C.CString(str)
	defer C.free_string(ptr)
	return makeXpath(C.xmlXPathCompile(C.to_xmlcharptr(ptr)))
}