When I unmarshal and marshal this XML the URL for the namespace disappear:
<root xmlns:urn="http://test.example.com">
<urn:copyright>tekst</urn:copyright>
</root>
Becomes:
<root xmlns:urn="">
<urn:copyright></urn:copyright>
</root>
The code:
package main
import (
"encoding/xml"
"fmt"
)
type Root struct {
XMLName xml.Name `xml:"root"`
XmlNS string `xml:"xmlns:urn,attr"`
Copyright Copyright `xml:"urn:copyright,omitempty"`
}
type Copyright struct {
Text string `xml:",chardata"`
}
func main() {
root := Root{}
x := `<root xmlns:urn="http://test.example.com">
<urn:copyright>text</urn:copyright>
</root>`
_ = xml.Unmarshal([]byte(x), &root)
b, _ := xml.MarshalIndent(root, "", " ")
fmt.Println(string(b))
}