MCPcopy Create free account
hub / github.com/antchfx/xmlquery / LoadURL

Function LoadURL

parse.go:21–32  ·  view source on GitHub ↗

LoadURL loads the XML document from the specified URL.

(url string)

Source from the content-addressed store, hash-verified

19
20// LoadURL loads the XML document from the specified URL.
21func LoadURL(url string) (*Node, error) {
22 resp, err := http.Get(url)
23 if err != nil {
24 return nil, err
25 }
26 defer resp.Body.Close()
27 // Make sure the Content-Type has a valid XML MIME type
28 if xmlMIMERegex.MatchString(resp.Header.Get("Content-Type")) {
29 return Parse(resp.Body)
30 }
31 return nil, fmt.Errorf("invalid XML document(%s)", resp.Header.Get("Content-Type"))
32}
33
34// Parse returns the parse tree for the XML from the given Reader.
35func Parse(r io.Reader) (*Node, error) {

Callers 2

TestLoadURLSuccessFunction · 0.85
TestLoadURLFailureFunction · 0.85

Calls 2

ParseFunction · 0.85
CloseMethod · 0.80

Tested by 2

TestLoadURLSuccessFunction · 0.68
TestLoadURLFailureFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…