diff --git a/iq.go b/iq.go index a34a919..1b174f6 100644 --- a/iq.go +++ b/iq.go @@ -166,7 +166,13 @@ type Node struct { } func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { - n.Attrs = start.Attr + // Assign "n.Attrs = start.Attr", without repeating xmlns in attributes + for _, attr := range start.Attr { + // Do not repeat xmlns + if attr.Name.Local != "xmlns" { + n.Attrs = append(n.Attrs, attr) + } + } type node Node return d.DecodeElement((*node)(n), &start) } diff --git a/iq_test.go b/iq_test.go index 1eba656..ab85370 100644 --- a/iq_test.go +++ b/iq_test.go @@ -37,6 +37,7 @@ func TestGenerateIq(t *testing.T) { }, Nodes: []Node{ {XMLName: xml.Name{ + Space: "http://jabber.org/protocol/disco#info", Local: "identity", }, Attrs: []xml.Attr{