O'Reilly logo

Web Development with Django Cookbook - Second Edition by Aidas Bendoraitis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing data from an external XML file

The Last.fm file also allows you to take data from their services in XML format. In this recipe, I will show you how to do this.

Getting ready

To prepare importing top tracks from Last.fm in the XML format, follow these steps:

  1. Start with the first three steps from the Getting ready section in the Importing data from an external JSON file recipe.
  2. Then, let's check the structure of the XML endpoint (http://ws.audioscrobbler.com/2.0/?method=tag.gettoptracks&tag=disco&api_key=xxx&format=xml), as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <lfm status="ok">
      <tracks tag="disco" page="1" perPage="50" totalPages="26205" total="1310249">
        <track rank="1">
          <name>Billie Jean</name> <duration>293</duration> <mbid>f980fc14-e29b-481d-ad3a-5ed9b4ab6340</mbid> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required