Trying to parse sitemap xml data into struct

282 views
Skip to first unread message

Kuldeep Avsar

unread,
Mar 3, 2020, 7:49:10 AM3/3/20
to golang-nuts
I wrote a program to extract data from sitemaps's as this format

type URLSet struct {
Urls []SitemapURL `xml:"url"`
}

type SitemapURL struct {
Location string `xml:"loc"`
LastModifiedDate string `xml:"lastmod"`
ChangeFrequency string `xml:"changefreq"`
Priority string `xml:"priority"`
}

but some domains have other shape of xml file like this

type URLSet struct {
Urls []SitemapURL `xml:"url"`
}

type SitemapURL struct {
Location string `xml:"loc"`
ChangeFrequency string `xml:"changefreq"`
Priority string `xml:"priority"`
LastModifiedDate string `xml:"lastmod"`
}

Any body can help me to handle these both things at same time

C Banning

unread,
Mar 3, 2020, 8:07:16 AM3/3/20
to golang-nuts
The sequence of struct members doesn't matter - https://play.golang.org/p/m0wZtHcPRcU
Reply all
Reply to author
Forward
0 new messages