tester
tester

Reputation: 35

what happen, my code cannot display result after parse XML in Go Lang?

I have XML like this

here my code XML

my description is correct or not with my code below :

type CustomerAndy struct {
    XMLName         xml.Name    `xml:"b:RelatedPartyList"`
    CustomerAndy    []DataLengkap   `xml:"b:RelatedParty"`
}

type DataLengkap struct {
    XMLNAME   xml.Name `xml:"b:RelatedParty"`
    FullName    string  `xml:"b:FullName"`
    Ktp         string  `xml:"b:IDNumber"`
    PefindoId   string  `xml:"b:CreditinfoId"`
    Address     string  `xml:"c:AddressLine"`

}

and this my full code go lang to parse XML :

here my full code go lang

why my code , I have change any way ,without looping, with looping, but not display result from parse XML , what wrong with my code ?

Upvotes: 0

Views: 53

Answers (1)

ssemilla
ssemilla

Reputation: 3968

When unmarshal-ing, remove the XML namespace (xmlns) prefixes. e.g.

type CustomerAndy struct {
    XMLName      xml.Name      `xml:"RelatedPartyList"`
    CustomerAndy []DataLengkap `xml:"RelatedParty"`
}

xml.Unmarshal already handles the namespaces.

Upvotes: 1

Related Questions