A Go package contains structs for all the types defined in the MESA International standards B2MML and BatchML schemas. It is a port of the C# B2MML.NET package.
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
b2mml "github.com/factrylabs/go-b2mml"
)
func main() {
data, _ := ioutil.ReadFile("/path/to/materiallot.xml")
ml := b2mml.MaterialLotType{}
_ := xml.Unmarshal(data, &ml)
fmt.Printf("Resulting B2MML struct:\n%+v\n", ml)
}
Why not generate directly from the B2MML schema? For a project we had to unmarshal some B2MML messages to Go structs. There is no mature xsd code generator for Go (yet, according to our experience), and it seemed much easier to simply "translate" the C# code generated by the Microsoft (R) Xml Schemas/DataTypes support utility (xsd.exe) than to write an xsd generator ourselves.
Feel free to open an issue or a to submit a pull request...
Thanks to jpdillingham for creating the C# version.