forked from kokardy/saxlike
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.go
More file actions
47 lines (43 loc) · 1.26 KB
/
Copy pathhandler.go
File metadata and controls
47 lines (43 loc) · 1.26 KB
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
47
package saxlike
import (
"encoding/xml"
)
//SAX-like handler
type Handler interface {
//called when XML document start
StartDocument()
//called when XML document end
EndDocument()
//called when XML tag start
StartElement(xml.StartElement)
//called when XML tag end
EndElement(xml.EndElement)
//called when the parser encount chardata
CharData(xml.CharData)
//called when the parser encount comment
Comment(xml.Comment)
//called when the parser encount procInst
//<!procinst >
ProcInst(xml.ProcInst)
//called when the parser encount directive
//
Directive(xml.Directive)
}
//VoidHandler is a implemented Handler
//All methods do nothing
//You need not implement all Handler methods.
/*
type PartialHandler struct{VoidHandler}
func (h PartialHandler) StartElement(xml.StartElement){
//do something
}
*/
type VoidHandler struct{}
func (h VoidHandler) StartDocument() {}
func (h VoidHandler) EndDocument() {}
func (h VoidHandler) StartElement(xml.StartElement) {}
func (h VoidHandler) EndElement(xml.EndElement) {}
func (h VoidHandler) CharData(xml.CharData) {}
func (h VoidHandler) Comment(xml.Comment) {}
func (h VoidHandler) ProcInst(xml.ProcInst) {}
func (h VoidHandler) Directive(xml.Directive) {}