// 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 }
func (xmlNode *XmlNode) Content() string { contentPtr := C.xmlNodeGetContent(xmlNode.Ptr) charPtr := (*C.char)(unsafe.Pointer(contentPtr)) defer C.xmlFreeChars(charPtr) return C.GoString(charPtr) }
// xmlNodeGetContent func (node *Node) GetContent() string { content := C.to_charptr(C.xmlNodeGetContent(node.Ptr)) defer C.free_string(content) return C.GoString(content) }
// 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 }