Ejemplo n.º 1
0
func (xmlNode *XmlNode) SetContent(content interface{}) (err error) {
	switch data := content.(type) {
	default:
		err = ERR_UNDEFINED_SET_CONTENT_PARAM
	case string:
		err = xmlNode.SetContent([]byte(data))
	case []byte:
		contentBytes := GetCString(data)
		contentPtr := unsafe.Pointer(&contentBytes[0])
		C.xmlSetContent(unsafe.Pointer(xmlNode), unsafe.Pointer(xmlNode.Ptr), contentPtr)
	}
	return
}
Ejemplo n.º 2
0
func (xmlNode *XmlNode) SetContent(content interface{}) (err error) {
	switch data := content.(type) {
	default:
		err = ERR_UNDEFINED_SET_CONTENT_PARAM
	case string:
		contentMutex.Lock()
		contentNode = xmlNode
		C.xmlSetContent(unsafe.Pointer(xmlNode.Ptr), C.CString(data))
		contentNode = nil
		contentMutex.Unlock()
	case []byte:
		err = xmlNode.SetContent(string(data))
	}
	return
}