Exemple #1
0
func NewNode(nodePtr unsafe.Pointer, document Document) (node Node) {
	if nodePtr == nil {
		return nil
	}
	xmlNode := &XmlNode{
		Ptr:      (*C.xmlNode)(nodePtr),
		Document: document,
		valid:    true,
	}
	nodeType := NodeType(C.getNodeType((*C.xmlNode)(nodePtr)))

	switch nodeType {
	default:
		node = xmlNode
	case XML_ATTRIBUTE_NODE:
		node = &AttributeNode{XmlNode: xmlNode}
	case XML_ELEMENT_NODE:
		node = &ElementNode{XmlNode: xmlNode}
	case XML_CDATA_SECTION_NODE:
		node = &CDataNode{XmlNode: xmlNode}
	case XML_COMMENT_NODE:
		node = &CommentNode{XmlNode: xmlNode}
	case XML_PI_NODE:
		node = &ProcessingInstructionNode{XmlNode: xmlNode}
	case XML_TEXT_NODE:
		node = &TextNode{XmlNode: xmlNode}
	}
	return
}
Exemple #2
0
func (xmlNode *XmlNode) NodeType() (nodeType NodeType) {
	nodeType = NodeType(C.getNodeType(xmlNode.Ptr))
	return
}
Exemple #3
0
func (xmlNode *XmlNode) NodeType() (nodeType int) {
	nodeType = int(C.getNodeType(xmlNode.Ptr))
	return
}