From 1411b9cc8b9a9259d247c4074f22fb26724e8a31 Mon Sep 17 00:00:00 2001 From: milampi <39635363+milampi@users.noreply.github.com> Date: Fri, 13 May 2022 11:24:06 +0300 Subject: [PATCH] Add xml attribute support for XMLElement (#136) * Save attributes of the xml element * Update unittest to check xml attributes --- xmpp.go | 1 + xmpp_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/xmpp.go b/xmpp.go index 8876483..669b45b 100644 --- a/xmpp.go +++ b/xmpp.go @@ -1009,6 +1009,7 @@ func (m *clientMessage) OtherStrings() []string { type XMLElement struct { XMLName xml.Name + Attr []xml.Attr `xml:",any,attr"` // Save the attributes of the xml element InnerXML string `xml:",innerxml"` } diff --git a/xmpp_test.go b/xmpp_test.go index 2966d98..ca7ec09 100644 --- a/xmpp_test.go +++ b/xmpp_test.go @@ -87,10 +87,12 @@ func TestStanzaError(t *testing.T) { OtherElem: []XMLElement{ XMLElement{ XMLName: xml.Name{Space: "google:mobile:data", Local: "gcm"}, + Attr: []xml.Attr{xml.Attr{Name:xml.Name{Space:"", Local:"xmlns"}, Value:"google:mobile:data"}}, InnerXML: "\n\t\t{\"random\": \"<text>\"}\n\t", }, XMLElement{ XMLName: xml.Name{Space: "jabber:client", Local: "error"}, + Attr: []xml.Attr{xml.Attr{Name:xml.Name{Space:"", Local:"code"}, Value:"400"},xml.Attr{Name:xml.Name{Space:"", Local:"type"}, Value:"modify"}}, InnerXML: `