Example #1
0
// Q1 Utility function to get the content of the nodes from a xpath query
// as a slice of strings
func (xp *Xp) QueryMulti(context *C.xmlNode, path string) (res []string) {
	nodes := xp.Query(context, path)

	for _, node := range nodes {
		content := C.xmlNodeGetContent(node)
		res = append(res, C.GoString((*C.char)(unsafe.Pointer(content))))
		C.free(unsafe.Pointer(content))
	}
	return
}
Example #2
0
func (xmlNode *XmlNode) Content() string {
	contentPtr := C.xmlNodeGetContent(xmlNode.Ptr)
	charPtr := (*C.char)(unsafe.Pointer(contentPtr))
	defer C.xmlFreeChars(charPtr)
	return C.GoString(charPtr)
}
Example #3
0
// xmlNodeGetContent
func (node *Node) GetContent() string {
	content := C.to_charptr(C.xmlNodeGetContent(node.Ptr))
	defer C.free_string(content)
	return C.GoString(content)
}
Example #4
0
// NodeGetContent gets the content of a node (or attribute)
func (xp *Xp) NodeGetContent(node *C.xmlNode) (res string) {
	content := C.xmlNodeGetContent(node)
	res = C.GoString((*C.char)(unsafe.Pointer(content)))
	C.free(unsafe.Pointer(content))
	return
}