2012-11-21 31 views
0

我在使用Google Picasa服务API时遇到了困难。Consuming Picasa API

比方说,我wan't通过jQuery显示该值:

<entry> 
<id> 
    https://picasaweb.google.com/data/entry/api/user/userID/albumid/albumID/photoid/5813338978197482482 
</id> 
<exif:tags> 
    <exif:time>1203311251000</exif:time> 
    <exif:imageUniqueID>uniqueID</exif:imageUniqueID> 
</exif:tags> 
<media:group> 
    <media:content url="https://lh6.googleusercontent.com/Penguins.jpg" height="384" width="512" type="image/jpeg" medium="image"/> 
    <media:credit>user</media:credit> 
    <media:description type="plain"/> 
    <media:keywords/> 
    <media:thumbnail url="https://lh6.googleusercontent.com/s72/Penguins.jpg" height="54" width="72"/> 
    <media:thumbnail url="https://lh6.googleusercontent.com/s144/Penguins.jpg" height="108" width="144"/> 
    <media:thumbnail url="https://lh6.googleusercontent.com/s288/Penguins.jpg" height="216" width="288"/> 
    <media:title type="plain">Penguins.jpg</media:title> 
</media:group> 
</entry> 

没有问题,从入门树读取值的时候,但是麻烦与Exif开始:标签或媒体:组。 这是函数读取XML

$(xml).find('entry').each(function() 
    { 
     var item = "" 
     item += "<li style='float:left;'>"; 
     item += $(this).find('title').text()  
     item += "</li>"; 
     $(".albums").append(item); 
    }); 

谢谢

+0

有一个问题在这里? http://www.whathaveyoutried.com –

+0

如何读取媒体内的值:group或exif:tags – jasenkoh

回答

1

水晶球时间!我猜正在尝试做这样的事情:

var $xml = $(/* get xml string from somewhere */); 
var $entryId = $xml.find('entry > id'); // works 
var $entryExifTags = $xml.find('entry > exif:tags'); // doesn't work 

这是因为some characters, including :, have special meaning in jQuery selectors. Therefore you need to escape them

var $entryExifTags = $xml.find('entry > exif\\:tags'); 
+0

正确,我也设法使用.children(foo \\:bar)读取这些值。现在如何读取像的值? – jasenkoh

+0

同样的道理。刚刚冒险结肠。 –