Пример #1
0
func (d *Document) SetVersion(e string) {
	if d.ptr.version != nil {
		C.MY_xmlFree(unsafe.Pointer(d.ptr.version))
	}

	d.ptr.version = C.xmlStrdup(stringToXmlChar(e))
}
Пример #2
0
func NewDocument(version, encoding string) *Document {
	doc := C.xmlNewDoc(stringToXmlChar(version))
	if encoding != "" {
		doc.encoding = C.xmlStrdup(stringToXmlChar(encoding))
	}
	return wrapDocument(doc)
}
Пример #3
0
func (d *Document) SetEncoding(e string) {
	if d.ptr.encoding != nil {
		C.MY_xmlFree(unsafe.Pointer(d.ptr.encoding))
	}

	d.ptr.encoding = C.xmlStrdup(stringToXmlChar(e))
}
Пример #4
0
func nodeValue(n Node) string {
	switch n.NodeType() {
	case AttributeNode, TextNode, CommentNode, CDataSectionNode, PiNode, EntityRefNode:
		return xmlCharToString(C.xmlXPathCastNodeToString((*C.xmlNode)(n.pointer())))
	case EntityDecl:
		np := (*C.xmlNode)(n.pointer())
		if np.content != nil {
			return xmlCharToString(C.xmlStrdup(np.content))
		}

		panic("unimplmented")
	}

	return ""
}
Пример #5
0
func (d *Document) URI() string {
	return xmlCharToString(C.xmlStrdup(d.ptr.URL))
}