Example #1
0
func (n *xmlNode) SetNodeValue(value string) {
	// TODO: Implement this in C
	if n.NodeType() != AttributeNode {
		C.xmlNodeSetContent(n.ptr, stringToXmlChar(value))
		return
	}

	ptr := n.ptr
	if ptr.children != nil {
		ptr.last = nil
		C.xmlFreeNodeList(ptr.children)
	}

	ptr.children = C.xmlNewText(stringToXmlChar(value))
	ptr.children.parent = ptr
	ptr.children.doc = ptr.doc
	ptr.last = ptr.children
}
Example #2
0
// xmlNodeSetContent
func (node *Node) SetContent(content string) {
	ptr := C.CString(content)
	defer C.free_string(ptr)
	C.xmlNodeSetContent(node.Ptr, C.to_xmlcharptr(ptr))
}
Example #3
0
// NodeSetContent sets the content of a node (or attribute)
func (xp *Xp) NodeSetContent(node *C.xmlNode, content string) {
	Ccontent := unsafe.Pointer(C.CString(content))
	C.xmlNodeSetContent(C.xmlNodePtr(node), (*C.xmlChar)(Ccontent))
	C.free(Ccontent)
}