Ejemplo n.º 1
0
func (n *XmlNode) Text() string {
	if !n.IsText() {
		return ""
	}

	return xmlCharToString(C.xmlNodeListGetString(nil, n.Ptr, 0))
}
Ejemplo n.º 2
0
func addIDAttr(node *C.xmlNode, attrName, nodeName, nsHref string) {
	// process children first because it does not matter much but does simplify code
	cur := C.xmlSecGetNextElementNode(node.children)
	for {
		if cur == nil {
			break
		}
		addIDAttr(cur, attrName, nodeName, nsHref)
		cur = C.xmlSecGetNextElementNode(cur.next)
	}

	if C.GoString((*C.char)(unsafe.Pointer(node.name))) != nodeName {
		return
	}
	if nsHref != "" && node.ns != nil && C.GoString((*C.char)(unsafe.Pointer(node.ns.href))) != nsHref {
		return
	}

	// the attribute with name equal to attrName should exist
	for attr := node.properties; attr != nil; attr = attr.next {
		if C.GoString((*C.char)(unsafe.Pointer(attr.name))) == attrName {
			id := C.xmlNodeListGetString(node.doc, attr.children, 1)
			if id == nil {
				continue
			}
			C.xmlAddID(nil, node.doc, id, attr)
		}
	}

	return
}
Ejemplo n.º 3
0
// xmlNodeListGetString
func (node *Node) ListGetString(inLine bool) string {
	ptr := node.Ptr
	docptr := C.xmlDocPtr((*C.xmlDoc)(ptr.doc))
	cInLine := C.int(0)
	if inLine {
		cInLine = C.int(1)
	}
	str := C.to_charptr(C.xmlNodeListGetString(docptr, ptr, cInLine))
	defer C.free_string(str)
	return C.GoString(str)
}