Skip to content

Latest commit

 

History

History
52 lines (37 loc) · 2.05 KB

README.md

File metadata and controls

52 lines (37 loc) · 2.05 KB

eurlex-model-go

Overview

eurlex-model-go implements the XML data model used by EUR-Lex in Golang. It is required by eurlex-ws-go, which implements the Webservice (Search), and Cellar.

Install

go get -u github.com/slipke/eurlex-model-go

Usage

Retrieve the XML from either the Webservice or Cellar, or alternatively directly from the website (i.e. celex:32008R1272 and click on "Download notice"). Afterwards, the resulting XML file can be parsed by using the exemplary code:

import (
	"encoding/xml"
	"io/ioutil"

	log "github.com/sirupsen/logrus"
	model "github.com/slipke/eurlex-model-go"
)


func main() {
	xmlBytes, err := ioutil.ReadFile("cellar_6bf54b59-7673-461b-b8e1-f24c545cbd3c.xml")
	if err != nil {
		log.Fatalf("Failed to load file %s: %s", file, err)
	}

	var n *model.Notice

	err = xml.Unmarshal(xmlBytes, &n)
	if err != nil {
		log.Fatalf("Failed to parse xml: %s", err)
	}

	// Print notice
	log.Info(n)
}

Resources