sitemap

package module
v0.0.0-...-52a1fb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 1 Imported by: 0

README

go.dpb.io/sitemap

Stream decoders for sitemap.xml data and link feeds.

  • supports multiple file formats - traditional sitemap.xml files, syndication feeds (Atom, RSS), and plain text files
  • supports extensions - xhtml:link localizations, 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

Usage

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.

Alternatives

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

Decode is the default decoder which supports XML files with common extensions.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
examples
aggregate
This example shows how EntryAggregate can be used to read all entries into memory so they can be iterated on after (vs the traditional manner of handling each entry individually as they are parsed from a stream).
This example shows how EntryAggregate can be used to read all entries into memory so they can be iterated on after (vs the traditional manner of handling each entry individually as they are parsed from a stream).
reader
This example shows the common approach of handling each entry as it is parsed and looking at individual fields for further use.
This example shows the common approach of handling each entry as it is parsed and looking at individual fields for further use.
recurse
This example uses the built-in fetcher which downloads a URL and, by default, automatically recurses any child sitemaps it finds.
This example uses the built-in fetcher which downloads a URL and, by default, automatically recurses any child sitemaps it finds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL