// Parse parses an xml feed into an rss.Feed func (rp *Parser) Parse(feed io.Reader) (*Feed, error) { p := xpp.NewXMLPullParser(feed, false, shared.NewReaderLabel) _, err := shared.FindRoot(p) if err != nil { return nil, err } return rp.parseRoot(p) }
// Parse parses an xml feed into an atom.Feed func (ap *Parser) Parse(feed io.Reader) (*Feed, error) { fr := shared.NewXMLSanitizerReader(feed) p := xpp.NewXMLPullParser(fr, false, charset.NewReaderLabel) _, err := shared.FindRoot(p) if err != nil { return nil, err } return ap.parseRoot(p) }
// DetectFeedType attempts to determine the type of feed // by looking for specific xml elements unique to the // various feed types. func DetectFeedType(feed io.Reader) FeedType { p := xpp.NewXMLPullParser(feed, false, shared.NewReaderLabel) _, err := shared.FindRoot(p) if err != nil { return FeedTypeUnknown } name := strings.ToLower(p.Name) switch name { case "rdf": return FeedTypeRSS case "rss": return FeedTypeRSS case "feed": return FeedTypeAtom default: return FeedTypeUnknown } }