parser

package
v0.0.0-...-d53c238 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

this is based on https://github.com/grokify/wordpress-xml-go with just slight modifications for my use case

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	AuthorId          int        `xml:"author_id"`
	AuthorLogin       string     `xml:"author_login"`
	AuthorEmail       string     `xml:"author_email"`
	AuthorDisplayName string     `xml:"author_display_name"`
	AuthorFirstName   string     `xml:"author_first_name"`
	AuthorLastName    string     `xml:"author_last_name"`
	AuthorArticles    []ItemThin `xml:"-"`
}

Author is the WordPress XML author object.

type Category

type Category struct {
	Domain      string `xml:"domain,attr"`
	DisplayName string `xml:",chardata"`
	UrlSlug     string `xml:"nicename,attr"`
}

type Channel

type Channel struct {
	Title   string   `xml:"title"`
	Link    string   `xml:"link"`
	Authors []Author `xml:"author"`
	Items   []Item   `xml:"item"`
}

type Comment

type Comment struct {
	Id          int    `xml:"comment_id"`
	Parent      int    `xml:"comment_parent"`
	Author      string `xml:"comment_author"`
	AuthorEmail string `xml:"comment_author_email"`
	AuthorUrl   string `xml:"comment_author_url"`
	DateGmt     string `xml:"comment_date_gmt"`
	Content     string `xml:"comment_content"`
	IndentLevel int    `xml:"-"`
}

type Item

type Item struct {
	Id             int        `xml:"post_id"`
	Title          string     `xml:"title"`
	Creator        string     `xml:"creator"`
	Encoded        []string   `xml:"encoded"`
	IsSticky       int        `xml:"is_sticky"`
	Link           string     `xml:"link"`
	PubDate        string     `xml:"pubDate"`
	Description    string     `xml:"description"`
	PostDate       string     `xml:"post_date"`
	PostDateGmt    string     `xml:"post_date_gmt"`
	PostName       string     `xml:"post_name"`
	PostType       string     `xml:"post_type"`
	Status         string     `xml:"status"`
	Categories     []Category `xml:"category"`
	Content        string
	PubDateRfc3339 string
	Comments       []Comment `xml:"comment"`
}

Item is a WordPress XML item which can be a post, page or other object.

type ItemThin

type ItemThin struct {
	Title string
	Index int
}

ItemThin is a WordPress XML item that is used as additional metadata in the Author object.

type Rss

type Rss struct {
	Channel Channel `xml:"channel"`
}

type WpXml

type WpXml struct {
	Channel        Channel `xml:"channel"`
	CreatorCounts  map[string]int
	CreatorToIndex map[string]int
}

func NewWordpressXml

func NewWordpressXml() WpXml

func Parse

func Parse(path string) (error, *WpXml)

parse a WordPress XML export

func (*WpXml) ArticlesMetaTable

func (wpxml *WpXml) ArticlesMetaTable() [][]string

ArticlesMetaTable generates the data to be written out as a CSV.

func (*WpXml) AuthorForLogin

func (wpxml *WpXml) AuthorForLogin(authorLogin string) (Author, error)

AuthorForLogin returns the Author object for a given AuthorLogin or username.

func (*WpXml) AuthorsToIndex

func (wpxml *WpXml) AuthorsToIndex() map[string]int

func (*WpXml) ReadXml

func (wpxml *WpXml) ReadXml(filepath string) error

ReadXml reads a WordPress XML file from the provided path.

func (*WpXml) WriteMetaCsv

func (wpxml *WpXml) WriteMetaCsv(filepath string) error

Writes articles metadata as a CSV file.

Jump to

Keyboard shortcuts

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