opml

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2014 License: BSD-3-Clause Imports: 3 Imported by: 20

Documentation

Overview

Package opml provides all the required structures and functions for parsing OPML files, as defined by the specification of the OPML format:

[OPML 1.0] http://dev.opml.org/spec1.html
[OPML 2.0] http://dev.opml.org/spec2.html

It is able to parse both, OPML 1.0 and OPML 2.0, files.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Outlines []Outline `xml:"outline"`
}

Body is the parent structure of all outlines.

type Head struct {
	Title           string `xml:"title"`
	DateCreated     string `xml:"dateCreated,omitempty"`
	DateModified    string `xml:"dateModified,omitempty"`
	OwnerName       string `xml:"ownerName,omitempty"`
	OwnerEmail      string `xml:"ownerEmail,omitempty"`
	OwnerID         string `xml:"ownerId,omitempty"`
	Docs            string `xml:"docs,omitempty"`
	ExpansionState  string `xml:"expansionState,omitempty"`
	VertScrollState string `xml:"vertScrollState,omitempty"`
	WindowTop       string `xml:"windowTop,omitempty"`
	WindowBottom    string `xml:"windowBottom,omitempty"`
	WindowLeft      string `xml:"windowLeft,omitempty"`
	WindowRight     string `xml:"windowRight,omitempty"`
}

Head holds some meta information about the document.

type OPML

type OPML struct {
	XMLName xml.Name `xml:"opml"`
	Version string   `xml:"version,attr"`
	Head    Head     `xml:"head"`
	Body    Body     `xml:"body"`
}

OPML is the root node of an OPML document. It only has a single required attribute: the version.

func NewOPML

func NewOPML(b []byte) (*OPML, error)

NewOPML creates a new OPML structure from a slice of bytes.

func NewOPMLFromFile

func NewOPMLFromFile(filePath string) (*OPML, error)

NewOPMLFromFile creates a new OPML structure from a file.

Example
package main

import (
	"fmt"
	"log"

	"github.com/gilliek/go-opml/opml"
)

func main() {
	doc, err := opml.NewOPMLFromFile("path/to/file.xml")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(doc)
}
Output:

func NewOPMLFromURL

func NewOPMLFromURL(url string) (*OPML, error)

NewOPMLFromURL creates a new OPML structure from an URL.

func (OPML) Outlines

func (doc OPML) Outlines() []Outline

Outlines returns a slice of the outlines.

func (OPML) XML

func (doc OPML) XML() (string, error)

type Outline

type Outline struct {
	Outlines     []Outline `xml:"outline"`
	Text         string    `xml:"text,attr"`
	Type         string    `xml:"type,attr,omitempty"`
	IsComment    string    `xml:"isComment,attr,omitempty"`
	IsBreakpoint string    `xml:"isBreakpoint,attr,omitempty"`
	Created      string    `xml:"created,attr,omitempty"`
	Category     string    `xml:"category,attr,omitempty"`
	XMLURL       string    `xml:"xmlUrl,attr,omitempty"`
	HTMLURL      string    `xml:"htmlUrl,attr,omitempty"`
	URL          string    `xml:"url,attr,omitempty"`
	Language     string    `xml:"language,attr,omitempty"`
	Title        string    `xml:"title,attr,omitempty"`
	Version      string    `xml:"version,attr,omitempty"`
	Description  string    `xml:"description,attr,omitempty"`
}

Outline holds all information about an outline.

Jump to

Keyboard shortcuts

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