Skip to content

This projects implements the EUR-Lex XML data model in Golang. For more information see README.md

License

Notifications You must be signed in to change notification settings

slipke/eurlex-model-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This projects implements the EUR-Lex XML data model in Golang. For more information see README.md

Topics

Resources

License

Stars

Watchers

Forks