Help us shape the future of Go! Take the 2026 Go Developer Survey

wxr

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package wxr parses WordPress eXtended RSS exports (Tools → Export), the fallback source when the REST API hides data (postmeta such as the MCBB product mapping, drafts, menus).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID          int
	Login       string
	Email       string
	DisplayName string
}

Author is a wp:author entry.

type File

type File struct {
	Title       string
	Link        string
	Language    string
	BaseSiteURL string
	BaseBlogURL string
	Generator   string
	Version     string
	Authors     []Author
	Terms       []Term // categories, tags and wp:term entries, normalized
	Items       []Item
}

File is a parsed export.

func Parse

func Parse(r io.Reader) (*File, error)

Parse reads a WXR document.

func (*File) ItemsOfType

func (f *File) ItemsOfType(typ string) []Item

ItemsOfType returns the items with post_type typ.

type Item

type Item struct {
	ID            int
	Title         string
	Link          string
	Creator       string
	Content       string
	Excerpt       string
	PostDate      string
	PostDateGMT   string
	ModifiedGMT   string
	Name          string // post_name (slug, possibly percent-encoded)
	Status        string
	Parent        int
	MenuOrder     int
	Type          string
	AttachmentURL string
	Terms         []ItemTerm
	Meta          map[string]string
}

Item is an <item>: a post of any type (post, page, attachment, product, nav_menu_item, …).

func (Item) MetaInt

func (it Item) MetaInt(key string) int

MetaInt returns Meta[key] as an int (0 if absent or invalid).

func (Item) TermsIn

func (it Item) TermsIn(domain string) []string

TermsIn returns the item's term slugs in taxonomy domain.

type ItemTerm

type ItemTerm struct {
	Domain   string
	Nicename string
	Name     string
}

ItemTerm is a <category domain="…" nicename="…"> on an item.

type Term

type Term struct {
	ID          int
	Taxonomy    string
	Slug        string
	Name        string
	Parent      string
	Description string
}

Term is a taxonomy term. Parent is the parent's slug (WXR references parents by slug).

Jump to

Keyboard shortcuts

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