// xmlNewNode func NewNode(ns *Namespace, name string) *Node { ptr := C.CString(name) defer C.free_string(ptr) if ns != nil { return makeNode(C.xmlNewNode(ns.Ptr, C.to_xmlcharptr(ptr))) } return makeNode(C.xmlNewNode(nil, C.to_xmlcharptr(ptr))) }
func (document *XmlDocument) CreateElementNode(tag string) (element *ElementNode) { tagBytes := GetCString([]byte(tag)) tagPtr := unsafe.Pointer(&tagBytes[0]) newNodePtr := C.xmlNewNode(nil, (*C.xmlChar)(tagPtr)) newNode := NewNode(unsafe.Pointer(newNodePtr), document) element = newNode.(*ElementNode) return }
func (d *Document) CreateElement(name string) (*Element, error) { if C.MY_test_node_name(stringToXmlChar(name)) == 0 { return nil, ErrInvalidNodeName } newNode := C.xmlNewNode(nil, stringToXmlChar(name)) if newNode == nil { return nil, errors.New("element creation failed") } // XXX hmmm... newNode.doc = d.ptr return wrapElement((*C.xmlElement)(unsafe.Pointer(newNode))), nil }