0

How can I get the image url which embeded in below media: thumbnail tag ?

<link href="http://example.com" type="text/html">
<media:content>
<media:thumbnail url="http://example2.com/1.jpg" width="150" height="100"></media:thumbnail>
</media:content>
</link>

I am looking for something like

var link = tag.querySelectorAll('link')[0];
var media = link.querySelector('media:content');
var thumbnail= link.querySelector('media:thumbnail');
var url= thumbnail.getAttribute('url');

but obviousely querySelector could not retrieve the value of media:content

Ali Esmailian
  • 979
  • 3
  • 9
  • 8
  • Have a look at these posts http://stackoverflow.com/questions/1121933/parsing-xml-using-php http://stackoverflow.com/questions/1597746/php-domdocument-getting-attribute-of-tag – mguimard Aug 08 '13 at 14:37
  • The cited duplicates are PHP oriented, not JavaScript. – izb Aug 09 '13 at 11:21

2 Answers2

1

Simply to use attr

jsfiddle example

JTC
  • 3,344
  • 3
  • 28
  • 46
  • 1
    Thanks, it is good when you access to jquery library I am using javascript and I did manage to get it by below code var mediaThumbnail = link.getElementsByTagName('thumbnail')[0]; var imageUrl = mediaThumbnail.getAttribute('url'); – Ali Esmailian Aug 08 '13 at 14:53
0
$('media:thumbnail').attr('url');

This may help you

K Cloud
  • 271
  • 1
  • 5
  • 15