Beispiel #1
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
}
Beispiel #2
0
// GetAttr gets the value of the non-namespaced attribute attr
func (node *C.xmlNode) GetAttr(attr string) (res string) {
	Cattr := (*C.xmlChar)(unsafe.Pointer(C.CString(attr)))
	value := (*C.char)(unsafe.Pointer(C.xmlGetProp(node, Cattr)))
	C.free(unsafe.Pointer(Cattr))
	res = C.GoString(value)
	C.free(unsafe.Pointer(value))
	return
}
Beispiel #3
0
// If you need to check for the existence of an attribute,
// use Attribute.
func (xmlNode *XmlNode) Attr(name string) (val string) {
	if xmlNode.NodeType() != XML_ELEMENT_NODE {
		return
	}
	nameBytes := GetCString([]byte(name))
	namePtr := unsafe.Pointer(&nameBytes[0])
	valPtr := C.xmlGetProp(xmlNode.Ptr, (*C.xmlChar)(namePtr))
	if valPtr == nil {
		return
	}
	p := unsafe.Pointer(valPtr)
	defer C.xmlFreeChars((*C.char)(p))
	val = C.GoString((*C.char)(p))
	return
}
Beispiel #4
0
func XmlGetProp(n *C.xmlNode, name string) string {
	c := C.xmlCharStrdup(C.CString(name))
	s := C.xmlGetProp(n, c)
	return xmlCharToString(s)
}
Beispiel #5
0
func (n *XmlNode) Attr(name string) string {
	xname := stringToXmlChar(name)
	return xmlCharToString(C.xmlGetProp(n.Ptr, xname))
}