Allow entries to be published without any outer feed

This commit is contained in:
Jason Streifling 2024-10-18 05:00:24 +02:00
parent 9445a7c4cd
commit 3c312aa3ed

View File

@ -249,3 +249,13 @@ func (e *Entry) Check() error {
return nil 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(`<?xml version="1.0" encoding="`+encoding+`"?>`) + string(xml), nil
}