用Go解析XML文件的行为很奇怪

<?xml version="1.0" encoding="UTF-8"?>
<Courbe>
  <Entete>
    <Identifiant_Flux>RD</Identifiant_Flux>
    <Libelle_Flux>@@@</Libelle_Flux>
    <Identifiant_Emetteur>xxx</Identifiant_Emetteur>
    <Identifiant_Destinataire>1000000</Identifiant_Destinataire>
    <Date_Creation>2010-08-02T05:10:05+02:00</Date_Creation>
    <Frequence_Publication>Q</Frequence_Publication>
    <Reference_Demande>123456</Reference_Demande>
    <Nature_De_Courbe_Demandee>Brute</Nature_De_Courbe_Demandee>
  </Entete>
<Corps>
  <Identifiant>30000000000</Identifiant>
  <Donnees_Courbe>
    <Horodatage_Debut>2010-08-02T00:00:00+02:00</Horodatage_Debut>
    <Horodatage_Fin>2010-08-02T23:59:59+02:00</Horodatage_Fin>
    <Granularite>10</Granularite>
    <Unite_Mesure>kW</Unite_Mesure>
    <Grandeur_Metier>CONS</Grandeur_Metier>
    <Grandeur_Physique>EA</Grandeur_Physique>
    <Donnees_Point_Mesure Horodatage ="2010-08-02T00:00:00+02:00" Valeur_Point ="10" Statut_Point ="R"></Donnees_Point_Mesure>
    <Donnees_Point_Mesure Horodatage ="2010-08-02T00:10:00+02:00" Valeur_Point ="10" Statut_Point ="R"></Donnees_Point_Mesure>
    <Donnees_Point_Mesure Horodatage ="2010-08-02T00:20:00+02:00" Valeur_Point ="10" Statut_Point ="R"></Donnees_Point_Mesure>
  </Donnees_Courbe>
  <Donnees_Courbe>
    <Horodatage_Debut>2010-08-02T00:00:00+02:00</Horodatage_Debut>
    <Horodatage_Fin>2010-08-02T23:59:59+02:00</Horodatage_Fin>
    <Granularite>10</Granularite>
    <Unite_Mesure>kVAr</Unite_Mesure>
    <Grandeur_Metier>CONS</Grandeur_Metier>
    <Grandeur_Physique>ERI</Grandeur_Physique>
    <Donnees_Point_Mesure Horodatage ="2010-08-02T00:00:00+02:00" Valeur_Point ="6" Statut_Point ="R"></Donnees_Point_Mesure>
    <Donnees_Point_Mesure Horodatage ="2010-08-02T00:10:00+02:00" Valeur_Point ="5" Statut_Point ="R"></Donnees_Point_Mesure>
  </Donnees_Courbe>
</Corps>
</Courbe>

Here are the structures I use to parse it.

type Flow struct {
    XMLName    xml.Name `xml:"Courbe"`
    PathToFile string
    Entete     flowHeader
    Corp       flowBody
}


type flowHeader struct {
    XMLName         xml.Name  `xml:"Entete"`
    IDFlux          string    `xml:"Identifiant_Flux"`
    LabelFlux       string    `xml:"Libelle_Flux"`
    IDEmetteur      string    `xml:"Identifiant_Emetteur"`
    IDDestinataire  uint32    `xml:"Identifiant_Destinataire"`
    DateCreation    time.Time `xml:"Date_Creation"`
    FreqPublication string    `xml:"Frequence_Publication"`
    RefDemande      uint32    `xml:"Reference_Demande"`
    NatureCourbe    string    `xml:"Nature_De_Courbe_Demandee"`
}

type flowBody struct {
    XMLName   xml.Name `xml:"Corps"`
    PRM       string   `xml:"Identifiant"`
    DonneeCDC flowDataCDC
}

type flowDataCDC struct {
    XMLName       xml.Name                    `xml:"Donnees_Courbe"`
    HorodateDebut time.Time                   `xml:"Horodatage_Debut"`
    HorodateFin   time.Time                   `xml:"Horodatage_Fin"`
    Granularite   uint32                      `xml:"Granularite"`
    Unite         string                      `xml:"Unite_Mesure"`
    GrdMetier     string                      `xml:"Grandeur_Metier"`
    GrdPhysique   string                      `xml:"Grandeur_Physique"`
    Donnes        []flowMeasurePoint `xml:"Donnees_Point_Mesure"`
}

Initially, I had only 1 Donnees_Courbe, so it was OK. Now, I have 2 ( Only the first one is important to me, I want to ignore the second one )

Thing is, in the flowBody struct, I change the last field to an array:

type flowBody struct {
    XMLName   xml.Name `xml:"Corps"`
    PRM       string   `xml:"Identifiant"`
    DonneeCDC []flowDataCDC
}

but it doesnt work, my data is nil.

If I let it without an DonneeCDC array, it will parse my file, but it says that all my data has Unite_Mesure=kVAr, which is obviously not what I want.

How should I parse it well ?

Adding the struct tag to the field containing the slice should work:

type flowBody struct {
    XMLName   xml.Name      `xml:"Corps"`
    PRM       string        `xml:"Identifiant"`
    DonneeCDC []flowDataCDC `xml:"Donnees_Courbe"` // tag added
}

type flowDataCDC struct {
    XMLName       xml.Name           `xml:"Donnees_Courbe"` // this may be removed.
    HorodateDebut time.Time          `xml:"Horodatage_Debut"`
    HorodateFin   time.Time          `xml:"Horodatage_Fin"`
    Granularite   uint32             `xml:"Granularite"`
    Unite         string             `xml:"Unite_Mesure"`
    GrdMetier     string             `xml:"Grandeur_Metier"`
    GrdPhysique   string             `xml:"Grandeur_Physique"`
    Donnes        []flowMeasurePoint `xml:"Donnees_Point_Mesure"`
}