Reputation: 19203
Can you generate XML dynamically in GO? Instead of using a struct and then doing .Encode
on it?
So something like you can do in Python by using lxml. As in building one Element after another manually and dynamically as needed.
This way I can add only the fields/elements I need based on custom logic.
Upvotes: 1
Views: 815
Reputation: 534
You can add dynamic attributes to a type that contains a map, and define a custom marshalling action on this type. There's an example here: Marshall map to XML in Go
Upvotes: 3