TraktorNmlUtils/models/collection/CollectionHandler.go
2024-10-11 15:25:16 +02:00

25 lines
509 B
Go

package collection
import (
"encoding/xml"
"os"
)
// ReadFileAndConvertToCollection reads a file and converts it to the Collection struct
func ReadFileAndConvertToCollection(filePath string) (*NML, error) {
// Read the file content
fileContent, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
// Unmarshal the XML content into the Collection struct
var collection NML
err = xml.Unmarshal(fileContent, &collection)
if err != nil {
return nil, err
}
return &collection, nil
}