示例#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))
}