Here is the XML structure:
<root xmlns:test="http://test.com/testns">
<test:sub>
<title>this is title</title>
</test:sub>
</root>
It gets unmarshalled with the structs defined below:
type Root struct {
XMLName xml.Name `xml:"root"`
Sub *Sub
}
type Sub struct {
XMLName xml.Name `xml:"http://test.com/testns sub"`
Title string `xml:"title"`
}
This is what gets marshalled back:
<root>
<sub xmlns="http://test.com/testns">
<title>this is title</title>
</sub>
</root>
The root namespace prefix definition gets removed after the marshal and the sub element is using url namespace instead of the prefix. Here is the code
Is there any way that marshal/unmarshal won't change the xml structure? thanks!