Open
Description
What version of Go are you using (go version
)?
$ go version go version 1.13.5 windows/amd64
Does this issue reproduce with the latest release?
Yes, behaves same on 1.13.7
What operating system and processor architecture are you using (go env
)?
Windows/amd64 but this is repeatable at least on linux
go env
Output
$ go env
What did you do?
I set up a struct with
I set up this set of structures
type myGetValueResponseEnvelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Body myGetValueResponseBody
}
type myGetValueResponseBody struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
Value string `xml:"getValueResponse>getValueReturn"`
}
to decode this XML:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getValueResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getValueReturn xsi:type="xsd:string">69.1</getValueReturn>
</getValueResponse>
</soapenv:Body>
</soapenv:Envelope>
but I wanted to eliminate the second object by using a>b>c syntax. Note though that the soapenv namespace is as far as Body but not farther. So I attempted this
type myGetValueResponseEnvelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Value string `xml:"http//schemas.xmlsoap.org/soap/envelope Envelope>getValueResponse>getValueReturn"`
}
but it doesn't SEEM with a>b>c syntax that there's any way to have namespaces in all or (in my case) part of the xpath.
I can just eliminate the namespace requirement on Body and it actually decodes just fine, so this isn't an urgent issue at the moment, but some day I may want to be more selective. Regardless it seems the answer would be to split on > then ' ' then process it as usual.