Ejemplo n.º 1
0
func (x *XPathContext) Free() {
	if x.ptr == nil {
		return
	}

	C.xmlXPathFreeContext(x.ptr)
}
Ejemplo n.º 2
0
func (xpath *XPath) Free() {
	if xpath.ContextPtr != nil {
		C.xmlXPathFreeContext(xpath.ContextPtr)
		xpath.ContextPtr = nil
	}
	if xpath.ResultPtr != nil {
		C.xmlXPathFreeObject(xpath.ResultPtr)
		xpath.ResultPtr = nil
	}
}
Ejemplo n.º 3
0
func (d *XmlDoc) XPath(xpathExpr string) *XPathResult {
	context := C.xmlXPathNewContext(d.Ptr)
	defer C.xmlXPathFreeContext(context)

	result := C.xmlXPathEvalExpression(stringToXmlChar(xpathExpr), context)

	fmt.Println("XPath: ", xpathExpr, " Type: ", result._type, " Result: ", result)

	return &XPathResult{ptr: result}
}
Ejemplo n.º 4
0
func (xpath *XPath) Free() {
	if xpath.ContextPtr != nil {
		ClearScope(unsafe.Pointer(xpath.ContextPtr))
		C.xmlXPathFreeContext(xpath.ContextPtr)
		xpath.ContextPtr = nil
	}
	if xpath.ResultPtr != nil {
		C.xmlXPathFreeObject(xpath.ResultPtr)
		xpath.ResultPtr = nil
	}
}
Ejemplo n.º 5
0
func (n *XmlNode) XPath(xpathExpr string) *XPathResult {
	context := C.xmlXPathNewContext((C.xmlDocPtr)(unsafe.Pointer(n.Ptr.doc)))
	context.node = n.Ptr
	defer C.xmlXPathFreeContext(context)

	result := C.xmlXPathEvalExpression(stringToXmlChar(xpathExpr), context)

	fmt.Println("XPath: ", xpathExpr, " Type: ", result._type, " Result: ", result)

	return &XPathResult{ptr: result}
}
Ejemplo n.º 6
0
// xmlXPathFreeContext
func (ctx *XPathContext) Free() {
	C.xmlXPathFreeContext(ctx.Ptr)
	ctx.Ptr = nil
}
Ejemplo n.º 7
0
// Free the libxml2 allocated objects
func (xp *HtmlXp) free() {
	C.xmlXPathFreeContext(xp.xpathCtx)
	xp.xpathCtx = nil
	C.xmlFreeDoc(xp.doc)
	xp.doc = nil
}
Ejemplo n.º 8
0
// Free a xmlPathContext, but not the document
func (xp *Xp) freexpathCtx() {
	C.xmlXPathFreeContext(xp.xpathCtx)
	xp.xpathCtx = nil
	xp.doc = nil
	xp.master = nil
}