Step-by-step instructions on how to use Views Data Export (version 6.x-2.0-beta6) to export Pages (including those with multiple tags) into an XML file. This can help you migrate your Pages from a Drupal 6 site into a site running a newer version of Drupal. If you don't want to read through all the instructions, see the attached sample Views Import code that you can use to automatically create this View (although you will need to change the content types and taxonomy vocabularies to match types and vocabularies on your site).

Initial settings for a View that exports pages

After you decide to "Add" a new view (at admin/build/views/add ), below are the recommended settings for fields on the first screen when exporting pages. This assumes you arel only exporting ONE page type at a time (for example, type1 could be "Blog Posts", and then type2 might be "News articles").

  • View name: all_export_pages_type1 (I like my export views to show up at the top of my Views list, so I start the machine name with the word "all".)
  • Human readable name: Export Pages (type1)
  • View description: Export all Pages of type "type1" as an XML file
  • View tag: migrate (This OPTIONAL tag is how I organize my views, so that I can easily find those I'm using to migrate content.)
  • View type: Node

Tips about Live Preview and Saving

As a general rule, I recommend two good habits when editing Views. First, in your general Views settings (under "Tools" at admin/build/views/tools) check the box for "Disable automatic live preview". The Live Preview can cause JavaScript-related slowness and errors that are annoying. I also recommend that you click on the "Save" button after every change you make to each specific View, so that you don't lose your settings.

Default Settings

Here are the settings you need on the "Defaults" screen.

Basic Settings

Under the "Basic Settings" heading, make the following changes.

  • Change "Access" from "Unrestricted" to "Role" and then check only "Administrator" (or whatever name you've given to this role on your site), as you may not want to reveal all of this to the universe.
  • Change "Use pager" from "Paged, 10 items" to "Display all items" (leave the Offset at the default number of "0").
  • Remember to click on "Save" and then, after waiting for the Save message at the top of the page (such as "The view Export Pages (type1) has been saved.").

Filters

  • Choose the plus symbol to "Add" a filter that will limit the Pages you export to only one content type.
  • Choose "Node: Type" and "Node: Published" and click on "Add".
  • For Type, Leave "Operator" as "Is one of" and, under "Options", check the box next to your content type, such as "Blog entry" or "type1".
  • You can even add an "Administrative Title" that explains what this filter does, like "Limit to type1".
  • For Published, choose the button next to "Yes".
  • You might also add an "Administrative Title" that explains what this filter does, like "Limit to published".
  • Click on "Update".
  • Remember to click on "Save" and then wait for the Save message at the top of the page.

Fields (for Nodes)

Under "Fields", here are the recommended page-related settings. First, choose the plus symbol to "Add" a field you want to export. If you have a lot of fields on your site, you may want to choose "Node" from the drop-down menu under "Groups" so you can limit the number of fields you need to look through.

There are two fields that use only the default settings and don't need configured. These are "Node: Path" and "Node: Body". The other Node fields need configured to output content that is formatted to be clean in migrations.

  • For "Node: Nid", change the Label from "Nid" to "ID".
  • For "Node: Title", UN-check the box at the bottom that says "Link this field to its node".
  • For "Node: Type", check the box at the bottom that says "Output machine name".
  • For "Node: Updated date", change the label to "Updated" and, if you need to change the date format, you can choose "Custom" from the "Date format" dropdown box and enter the format you need, such as "Y-m-d H:i:s O".

Fields (for Tags)

Now, choose "Taxonomy" from the drop-down menu under "Groups" and check the box next to the "Taxonomy: All terms" field. Then, make these changes to that field's configuration:

  • Change Label from "All terms" to the simpler "Tags".
  • Change the "Simple separator" at the bottom from a comma with a space, to a semicolon with no space after it ";", or to another punctuation mark that is NOT used in any of your tags.
  • Finally, UN-check the box that says "Link this field to its term page".

Remember to click on "Save" and then wait for the Save message at the top of the page.

Add XML display

Underneath the top left of the screen, where you read "Defaults", there is also a drop-down list. Choose "Data export" from this list and then click on the "Add display" button underneath it. This lets us make specific configurations for XML, so that our file of exported Pages works correctly. Here are recommended settings for the "Data export" screen.

Basic Settings

Under the "Basic Settings" heading, make the following changes.

  • Machine Name: change from "views_data_export_1" to "all_export_pages_type1_xml"
  • Name: change from "Data export" to "XML".
  • Items to display: change from "10 items" to "Display all items" (leave the Offset at the default number of "0") and choose "Update default display".
  • Remember to click on "Save" and then wait for the Save message at the top of the page. For now, ignore the error message that says "Display "XML" uses a path but the path is undefined."

Style Settings

After this Save completes, click again on the newly-named display at the top left called "XML." Then, under the "Style Settings" heading, choose the following settings.

  • Click on "CSV file" and choose "XML file" instead. After you choose "Update", choose the following settings under "XML: Style options".
  • Check "Provide as file". (If you download the file of all your Pages, you don't have to worry about any slow networks or permissions issues when you are trying to import it into a new site.)
  • Filename: "export-pages-type1-%timestamp-full.xml" (This gives a clear name, which will end in a slightly different timestamp each time you download your file.)
  • Click "Update".
  • Remember to click on "Save" and then wait for the Save message at the top of the page.

Data export settings

After this Save completes, click again on the "XML" display at the top left. Then, under the "Data export settings" heading, choose the following settings.

  • Path: change from "None" to "export/pages/type1/xml".
  • Click "Update".
  • Remember to click on "Save" and then wait for the Save message at the top of the page.

Download and Test your Pages export file

Visit the path you created and download this file, for example: http://mysite.com/export/pages/type1/xml. If you open this file, you will probably see code that looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
  <node>
    <ID>403</ID>
    <Type>blog</Type>
    <Path>/blog/how-to-migrate-content-from-drupal6-to-drupal7-with-feeds-module</Path>
    <Title>How to easily migrate pages from Drupal 6 CCK content types to Drupal 7 fields using the Feeds module</Title>
    <Updated>2013-12-21 16:02:39 -0400</Updated>
    <Tags>drupal;libraries</Tags>
    <Body>&lt;img src="/sites/default/files/images/feeds-icon-drupalicon-d7small.jpg" alt="Feeds icon showing move from Drupal 6 to 7"&gt; One of the easiest ways to upgrade between version 6 and version 7 of Drupal is to re-build your site in Drupal 7, and then use the &lt;a href="http://drupal.org/project/views_data_export"&gt;Views Data Export&lt;/a&gt; and &lt;a href="http://drupal.org/project/feeds_xpathparser"&gt;Feeds XPath Parser&lt;/a&gt; modules to move your pages and articles into your new site. &lt;/p&gt;&lt;p&gt;</Body>
  </node>
</nodes>

Comments

aitala’s picture

What if your content type permitted a field with multiple values, say images in a slideshow? How would you export that without creating multiple entries in your XML file?

__________
Eric Aitala - ema13@psu.edu
Penn State

224b8605113373e086cb27708ff301ba18ce394db1996e7e22928e4555e0d20b1b6cecc7f67c9bd9e536cb915779c485

Ger0l’s picture

Would you recommend to do to download a xml file in zip-archive and save it to destination FTP with login and password?