Search

I’ve been looking to switch the backend of my personal site over to Symphony and part of that involves importing Flickr (and Tumblr + Twitter) into a database. I followed Nick’s screencast of XMLImporter (here) and got Twitter to import with no problems. However, I’ve tried the same method for importing Flickr photos but with no luck. I searched the forums here as well but couldn’t find a solution, so any help would be appreciated.

The API URL I’m using is http://api.flickr.com/services/feeds/photos_public.gne?id=44486351@N06&lang=en-us&format=rss2.0 so I’ve used ‘/feed/entry’ as the XPath, and I’ve attached the import settings I’m using.

When I run the importer no entries are found, any ideas?

Thanks a lot!

Attachments:
flickr_xml_import.gif

This has tripped me up before. Because the default XML namespace is being overridden and set to the Atom namespace:

<feed xmlns="http://www.w3.org/2005/Atom"...

You also need to import the atom namespace:

Namespace: atom
URI: http://www.w3.org/2005/Atom

The “Included elements” would then look like:

/atom:feed/atom:entry

I’ve not done this for Flickr per se, but my Github feed is identical and the above works. This confused me at first, since the atom namespace is never referenced explicitly in the XML, so I discovered this more by trial and error than judgment!

Oh, I should also mention that to get individual values you also need to prefix with the atom namespace. So your title would become:

atom:title/text()

Thanks Nick, works a treat! Glad I asked since I never would have worked that out

Sweet.

I’ve come accross another problem with XMLImporter, though this time with Tumblr. The Tumblr API feed is structured in a way that many of the useful attributes are stored in the post root node. For example:

http://demo.tumblr.com/api/read?type=regular (taking just regular post types)

I’m using the XPath /tumblr/posts/post to individual entries but can’t work out how to access the attributes in the post node like url-with-slug and date-gmt, etc. I’ve tried tons of variations on /@url-with-slug/text(), ../@url-with-slug/text() and so on, but no joy.

Any ideas? Thanks a lot

Attachments:
Screen shot 2010-11-23 at 10.08.52.png

Since post is the context node, you should simply need to do @url-with-slug/text().

/@url-with-slug points to the attribute url-with-slug on the root node of the document. ../@url-with-slug points to the attribute url-with-slug on the parent node (posts in this case).

Thanks for the reply froded, I thought that would work too but for some reason it doesn’t.. very strange.

I’ve never seen the use of text() in attributes… maybe you could try just @url-with-slug.

Ah that did the trick! Can’t believe it was something as simple as that, thanks a lot.

text() is for the textual contents of a node, not attributes.

True, I’ve never used text() for attributes either, but wrongly assumed it would work. You’re right in the sense that string values of attributes are not text nodes, just a plain string value. But to be pedantic, attributes are nodes as well :) And text() really just selects text nodes, as opposed to * which only selects element nodes.

My mind melted a bit the first time I realised that “text” was a node, as well as elements and attributes (among others).

Thanks for all the replies, finally understanding how to use XPath properly now!

Maybe this is helpful too?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details