Esempio n. 1
0
func (document *XmlDocument) CreateTextNode(data string) (text *TextNode) {
	dataBytes := GetCString([]byte(data))
	dataPtr := unsafe.Pointer(&dataBytes[0])
	nodePtr := C.xmlNewText((*C.xmlChar)(dataPtr))
	if nodePtr != nil {
		nodePtr.doc = (*_Ctype_struct__xmlDoc)(document.DocPtr())
		text = NewNode(unsafe.Pointer(nodePtr), document).(*TextNode)
	}
	return
}
Esempio n. 2
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
}
Esempio n. 3
0
func (d *Document) CreateTextNode(txt string) (*Text, error) {
	return wrapText(C.xmlNewText(stringToXmlChar(txt))), nil
}
Esempio n. 4
0
// xmlNewText
func NewText(content string) *TextNode {
	ptr := C.CString(content)
	defer C.free_string(ptr)
	return makeTextNode(C.xmlNewText(C.to_xmlcharptr(ptr)))
}