1 回答

TA貢獻(xiàn)1793條經(jīng)驗 獲得超6個贊
這似乎是這樣做的:
package main
import "encoding/xml"
var input = []byte(`
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.opentravel.org/OTA/2003/05">
</soap:Envelope>
`)
func main() {
var soap struct {
Attrs []xml.Attr `xml:",any,attr"`
XMLName xml.Name
}
err := xml.Unmarshal(input, &soap)
if err != nil {
panic(err)
}
println(soap.Attrs[1].Name.Local == "ns")
println(soap.Attrs[1].Value == "http://www.opentravel.org/OTA/2003/05")
println(soap.XMLName.Local == "Envelope")
}
- 1 回答
- 0 關(guān)注
- 224 瀏覽
添加回答
舉報