I need some values from xml:
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:consultaPontoResponse
xmlns:ns2="http://ws.consultaponto.senior.com/">
<return>
<clock>
<date>
<day>28</day>
<month>10</month>
<year>2017</year>
</date>
<time>
<hour>9</hour>
<minute>14</minute>
</time>
</clock>
<clock>
<date>
<day>28</day>
<month>10</month>
<year>2017</year>
</date>
<time>
<hour>11</hour>
<minute>51</minute>
</time>
</clock>
<clock>
<date>
<day>28</day>
<month>10</month>
<year>2017</year>
</date>
<time>
<hour>12</hour>
<minute>4</minute>
</time>
</clock>
<clock>
<date>
<day>28</day>
<month>10</month>
<year>2017</year>
</date>
<time>
<hour>12</hour>
<minute>27</minute>
</time>
</clock>
<workedTime>
<hour>3</hour>
<minute>0</minute>
</workedTime>
<currentDateTime>
<date>
<day>28</day>
<month>10</month>
<year>2017</year>
</date>
<time>
<hour>13</hour>
<minute>16</minute>
</time>
</currentDateTime>
</return>
</ns2:consultaPontoResponse>
</S:Body>
</S:Envelope>
And I create some structs to unmarshall :
type Envelope struct {
Body Body
}
type Body struct {
Consulta Consulta `xml: "consultaPontoResponse"`
}
type Consulta struct {
Return Return
}
type Clock struct {
Time Time
}
type Return struct {
Clock []Clock
}
type Time struct {
Hour string
Minute string
}
So I dont receive nothing when use :
xmlEnvelope := &Envelope{}
xml.Unmarshal(sonataXml, xmlEnvelope)
The return of xml.Unmarshal(sonataXml, xmlEnvelope)
is a empty object. This xml is a response of SOAP request and I don't need all the tag values. Can I get only specific tag values? Or do I need to create all structs to get values?