github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/spec/soap/spec.go (about) 1 package soap 2 3 import "encoding/xml" 4 5 type Speced interface { 6 Spec() Spec 7 } 8 9 type Spec interface { 10 Speced 11 Encode() *Node 12 Decode(*Node) 13 } 14 15 type Node struct { 16 XMLName xml.Name 17 Content []byte `xml:",innerxml"` 18 Nodes []Node `xml:",any"` 19 } 20 21 func Parse(content []byte) (*Node, error) { 22 var node Node 23 err := xml.Unmarshal(content, &node) 24 return &node, err 25 } 26 27 func (node *Node) Encode() ([]byte, error) { 28 return xml.MarshalIndent(node, "", "\t") 29 }