25 lines
509 B
Go
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
|
|
}
|