@@ -9,11 +9,6 @@ import (
9
9
"strings"
10
10
)
11
11
12
- type LeafNode struct {
13
- Path string `json:"path"`
14
- Value string `json:"value"`
15
- }
16
-
17
12
func XML (resp * http.Response ) (URLs []* url.URL , sitemap bool , err error ) {
18
13
xmlBody , err := io .ReadAll (resp .Body )
19
14
if err != nil {
@@ -27,12 +22,6 @@ func XML(resp *http.Response) (URLs []*url.URL, sitemap bool, err error) {
27
22
reader := bytes .NewReader (xmlBody )
28
23
decoder := xml .NewDecoder (reader )
29
24
30
- var (
31
- startElement xml.StartElement
32
- currentNode * LeafNode
33
- leafNodes []LeafNode
34
- )
35
-
36
25
// try to decode one token to see if stream is open
37
26
_ , err = decoder .Token ()
38
27
if err != nil {
@@ -54,8 +43,6 @@ func XML(resp *http.Response) (URLs []*url.URL, sitemap bool, err error) {
54
43
55
44
switch tok := tok .(type ) {
56
45
case xml.StartElement :
57
- startElement = tok
58
- currentNode = & LeafNode {Path : startElement .Name .Local }
59
46
for _ , attr := range tok .Attr {
60
47
if strings .HasPrefix (attr .Value , "http" ) {
61
48
parsedURL , err := url .Parse (attr .Value )
@@ -64,15 +51,7 @@ func XML(resp *http.Response) (URLs []*url.URL, sitemap bool, err error) {
64
51
}
65
52
}
66
53
}
67
- case xml.EndElement :
68
- if currentNode != nil {
69
- leafNodes = append (leafNodes , * currentNode )
70
- currentNode = nil
71
- }
72
54
case xml.CharData :
73
- if currentNode != nil && len (strings .TrimSpace (string (tok ))) > 0 {
74
- currentNode .Value = string (tok )
75
- }
76
55
if strings .HasPrefix (string (tok ), "http" ) {
77
56
parsedURL , err := url .Parse (string (tok ))
78
57
if err == nil {
0 commit comments