I am working with the following kind of an XML structure
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>TITLE</title>
<link>http://something.com</link>
<description>description</description>
<lastBuildDate>Mon, 19 Dec 2016 16:48:54 +0000</lastBuildDate>
<language>en</language>
<item>
<title>Title</title>
<description>description</description>
<author>
<name>Name</name>
<uri></uri>
</author>
<pubDate>Mon, 19 Dec 2016 16:42:32 +0000</pubDate>
<link>http://google.com</link>
<image>...</image>
<media:description><![CDATA[Natalie Massenet]]></media:description>
<media:credit>David Fisher/REX/Shutterstock</media:credit>
<category>Category1</category>
<category>Category2</category>
<guid isPermaLink="false">http://something.com/?p=10730393</guid>
<media:group></media:group>
<content:encoded>content</content:encoded>
</item>
</channel>
</rss>
I am having trouble figuring out how to deserialize <description>
and <media:description>
into two different element in a struct.
I've tried a following kind of a struct to represent an <item>
, but the value of media:description
ends up in the struct.
type Item struct {
// ...other fields
Description string `xml:"description"`
MediaDescription string `xml:"media:description"`
// ...other fields
}
What would be the best way to do this?