summaryrefslogtreecommitdiff
path: root/node.go
blob: 61650fb6b9816e1669b726f85fd81df1d337ef96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package query

import (
	"golang.org/x/net/html"
)

type NodeType uint32

const (
	ErrorNode     = NodeType(html.ErrorNode)
	TextNode      = NodeType(html.TextNode)
	DocumentNode  = NodeType(html.DocumentNode)
	ElementNode   = NodeType(html.ElementNode)
	CommentNode   = NodeType(html.CommentNode)
	DoctypeNode   = NodeType(html.DoctypeNode)
	AttributeNode = 100
	AnyNode       = 101
)

var NodeNames = map[NodeType]string{
	ErrorNode:     "ErrorNode",
	DocumentNode:  "DocumentNode",
	ElementNode:   "ElementNode",
	TextNode:      "TextNode",
	CommentNode:   "CommentNode",
	DoctypeNode:   "DoctypeNode",
	AttributeNode: "AttributeNode",
	AnyNode:       "AnyNode",
}

type Node interface {
	Parent() Node
	FirstChild() Node
	LastChild() Node
	PrevSibling() Node
	NextSibling() Node
	Type() NodeType
	Data() string
	InnerText() string
	DataType() string
	Attr() []Attribute
}

type Attribute struct {
	Namespace, Key, Val string
}