Stream decoders for sitemap.xml data and link feeds.
- supports multiple file formats - traditional
sitemap.xmlfiles, syndication feeds (Atom, RSS), and plain text files - supports extensions -
xhtml:linklocalizations, Google-specific (image sitemaps and Google News sitemap) - supports stream parsing (vs parsing all records into memory)
- utilities for resolving relative URLs, ignoring invalid locations, and fetching directly from a server
Import the base packages...
import (
"go.dpb.io/sitemap"
"go.dpb.io/sitemap/data"
)Create an EntryCallback for processing each Entry as it is decoded...
callback := data.EntryCallbackFunc(func (entry data.Entry) error {
if entryURL, ok := e.(*data.URL); ok {
fmt.Println(entryURL.Location)
}
return nil
})Use the default decoder which will auto-detect the encoding and supports some common extensions...
err := sitemap.Decode(reader, callback)Learn more from the examples directory, test files, and code documentation.
- oxffaa/gopher-parse-sitemap - stream parsing but doesn't support extensions
- yterajima/go-sitemap - loads everything into memory and doesn't support extensions