From 3c312aa3ed55760ef82347881eaf91033a857ab4 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Fri, 18 Oct 2024 05:00:24 +0200 Subject: [PATCH] Allow entries to be published without any outer feed --- entry.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/entry.go b/entry.go index 4eb7dd6..9086c72 100644 --- a/entry.go +++ b/entry.go @@ -249,3 +249,13 @@ func (e *Entry) Check() error { return nil } + +// ToXML converts the Feed to XML. It returns a string and an error. +func (e *Entry) ToXML(encoding string) (string, error) { + xml, err := xml.MarshalIndent(e, "", " ") + if err != nil { + return "", fmt.Errorf("error xml encoding entry: %v", err) + } + + return fmt.Sprintln(``) + string(xml), nil +}