Skip to content

Latest commit

 

History

History
101 lines (67 loc) · 1.53 KB

README.md

File metadata and controls

101 lines (67 loc) · 1.53 KB

go-opml

Build Status

go-opml aims to be a Go package for parsing OPML files.

This library is forked from https://github.com/gilliek/go-opml to add the following new features

Features

  • Ability to generate a new OPML file from scratch
  • Ability to add a RSS Feed from URL into an existing OPML struct

Installation

go get github.com/oxtyped/go-opml/opml

Usage

Parse OPML from file:

package main

import (
	"fmt"
	"log"

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

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

    xml, _ := doc.XML()
	fmt.Println(xml)

    //...
}

Parse OPML from URL:

package main

import (
	"fmt"
	"log"

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

func main() {
	doc, err := opml.NewOPMLFromURL("http://www.example.com/file.xml")
	if err != nil {
		log.Fatal(err)
	}

    xml, _ := doc.XML()
	fmt.Println(xml)

    //...
}

Generate a new OPML file from scratch and add RSS feeds manually:

package main

import (
	"fmt"
	"log"

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

func main(){

  doc := opml.NewOPMLFromBlank("title of OPML file")

  doc.AddRSSFeedFromURL("http://www.example.com/rss.xml")

  xml, _ := doc.XML()
  fmt.Println(xml)

  //...
}

Documentation

Document can be found on GoWalker or GoDoc

License

BSD 3-clauses