1
我需要從XML的一些值: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>
我創造一些結構來解讀:
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
}
,所以我不接受什麼時候使用:
xmlEnvelope := &Envelope{}
xml.Unmarshal(sonataXml, xmlEnvelope)
xml.Unmarshal(sonataXml, xmlEnvelope)
的返回是一個空對象。這個XML是SOAP請求的響應,我不需要所有的標記值。我只能得到特定的標籤值嗎?還是我需要創建所有結構以獲取值?
你想要什麼樣的價值觀? – md2perpe
全部「
只有'