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 }
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 }
// xmlXPathCompile func CompileXPath(str string) *XPath { ptr := C.CString(str) defer C.free_string(ptr) return makeXpath(C.xmlXPathCompile(C.to_xmlcharptr(ptr))) }