Пример #1
0
func makeHTMLDoc(doc C.htmlDocPtr) *HTMLDocument {
	if doc == nil {
		return nil
	}
	return &HTMLDocument{
		Ptr: doc,
		Document: &Document{
			Ptr:  C.xmlDocPtr(doc),
			Node: &Node{C.xmlNodePtr(unsafe.Pointer(doc))},
		},
		HTMLNode: &HTMLNode{
			Ptr:  C.htmlNodePtr(unsafe.Pointer(doc)),
			Node: &Node{C.xmlNodePtr(unsafe.Pointer(doc))},
		},
	}
}
Пример #2
0
func XmlGetProp(n unsafe.Pointer, name string) string {
	cname := C.CString(name)
	cstr := C.xmlGetProp(C.xmlNodePtr(n), cToXmlChar(cname))
	str := C.GoString(xmlCharToC(cstr))
	C.free(unsafe.Pointer(cname))
	return str
}
Пример #3
0
func HtmlNodeDump(n unsafe.Pointer) string {
	buf := C.xmlBufferCreate()
	C.htmlNodeDump(buf, nil, C.xmlNodePtr(n))
	cstr := C.xmlBufferContent(buf)
	str := C.GoString(xmlCharToC(cstr))
	C.xmlBufferFree(buf)
	return str
}
Пример #4
0
func makeDoc(doc C.xmlDocPtr) *Document {
	if doc == nil {
		return nil
	}
	return &Document{
		Ptr:  doc,
		Node: makeNode(C.xmlNodePtr(unsafe.Pointer(doc))),
	}
}
Пример #5
0
func (e *XmlElement) Type() ElementType {
	node_type := C.xmlNodePtr(e.ptr)._type
	return ElementType(node_type)
}
Пример #6
0
func (e *XmlElement) Name() string {
	node := unsafe.Pointer(C.xmlNodePtr(e.ptr).name)
	name := C.GoString((*C.char)(node))
	return name
}
Пример #7
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)
}
Пример #8
0
// NodeSetName sets the name/tag of a node
func (xp *Xp) NodeSetName(node *C.xmlNode, name string) {
	Cname := unsafe.Pointer(C.CString(name))
	C.xmlNodeSetName(C.xmlNodePtr(node), (*C.xmlChar)(Cname))
	C.free(Cname)
}
Пример #9
0
func XmlNextElementSibling(n unsafe.Pointer) unsafe.Pointer {
	return unsafe.Pointer(C.xmlNextElementSibling(C.xmlNodePtr(n)))
}
Пример #10
0
func XmlFirstElementChild(n unsafe.Pointer) unsafe.Pointer {
	return unsafe.Pointer(C.xmlFirstElementChild(C.xmlNodePtr(n)))
}