I have the following XML doc, and would like to convert the xml to object using happymapper.
<objects>
<item>
<title>book1</title>
<link>http://asdf.com</link>
<pubDate>march 1 2009</pubDate>
<description>testtesttest</description>
<media:thumbnail url='http://url.com' />
</item>
<item>
<title>book2</title>
<link>http://dffdfdf.com</link>
<pubDate>march 3 2009</pubDate>
<description>testtesttest</description>
<media:thumbnail url='http://url.com' />
</item>
</objects>
#HappyMapper object
class Item
include HappyMapper
namespace 'http://search.yahoo.com/mrss/'
element :title, String
element :link, String
element :pubDate, String
element :description, String
element :media_thumbnail, String, :tag=>'media:thumbnail', :attributes=>{:url=>String}
end
items=Item.parse(xml_document)
items.each do |i|
puts i.title
puts i.media_thumbnail.url
end
Error: Namespace prefix media on thumbnail is not defined at :11.
Error: Namespace prefix media on thumbnail is not defined at :22.
Check that your XML document has a namespace definition for prefix
media. Element<media:thumbnail>or one of its ancestors should have a namespace definition that looks likexmlns:media="http://some.uri". If there is no namespace-uri to prefix mapping, then your XML is not (namespace) well-formed which causes the parsing to fail.Check that you have defined the correct namespace for the
thumbnailelement in the HappyMapper code.