Reputation: 35
I have XML like this
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 :
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
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