Skip to content

Commit

Permalink
move Parse func back to original position in src to reduce diff size
Browse files Browse the repository at this point in the history
  • Loading branch information
jf-tech committed Aug 24, 2020
1 parent 8ad7724 commit db13d6a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ func LoadURL(url string) (*Node, error) {
return Parse(resp.Body)
}

// Parse returns the parse tree for the XML from the given Reader.
func Parse(r io.Reader) (*Node, error) {
p := createParser(r)
for {
_, err := p.parse()
if err == io.EOF {
return p.doc, nil
}
if err != nil {
return nil, err
}
}
}

type parser struct {
decoder *xml.Decoder
doc *Node
Expand Down Expand Up @@ -163,3 +149,17 @@ func (p *parser) parse() (*Node, error) {
}
}
}

// Parse returns the parse tree for the XML from the given Reader.
func Parse(r io.Reader) (*Node, error) {
p := createParser(r)
for {
_, err := p.parse()
if err == io.EOF {
return p.doc, nil
}
if err != nil {
return nil, err
}
}
}

0 comments on commit db13d6a

Please sign in to comment.