forked from jshiffer/go-xmpp
Add xml attribute support for XMLElement (#136)
* Save attributes of the xml element * Update unittest to check xml attributes
This commit is contained in:
parent
99ddfc1aa4
commit
1411b9cc8b
1
xmpp.go
1
xmpp.go
@ -1009,6 +1009,7 @@ func (m *clientMessage) OtherStrings() []string {
|
|||||||
|
|
||||||
type XMLElement struct {
|
type XMLElement struct {
|
||||||
XMLName xml.Name
|
XMLName xml.Name
|
||||||
|
Attr []xml.Attr `xml:",any,attr"` // Save the attributes of the xml element
|
||||||
InnerXML string `xml:",innerxml"`
|
InnerXML string `xml:",innerxml"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +87,12 @@ func TestStanzaError(t *testing.T) {
|
|||||||
OtherElem: []XMLElement{
|
OtherElem: []XMLElement{
|
||||||
XMLElement{
|
XMLElement{
|
||||||
XMLName: xml.Name{Space: "google:mobile:data", Local: "gcm"},
|
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",
|
InnerXML: "\n\t\t{\"random\": \"<text>\"}\n\t",
|
||||||
},
|
},
|
||||||
XMLElement{
|
XMLElement{
|
||||||
XMLName: xml.Name{Space: "jabber:client", Local: "error"},
|
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: `
|
InnerXML: `
|
||||||
<bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
|
<bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
|
||||||
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
|
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
|
||||||
|
Loading…
Reference in New Issue
Block a user