1
아무것도 돌려주지 않는 비 정렬 화 :XML 구문 분석/I는 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
모두 "
'