How to install it?

1
drush -y en feeds feeds_ex feeds_ui

Feeds Ex module provides the XML Parser. Make sure you enable the Feeds Admin module (feeds_ui).

Import data from XML as nodes

Create a file data.xml somewhere with this content (this will be our data source):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<books>
  <book>
    <title>War and Peace</title>
    <author>Leo Tolstoi</author>
    <description>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </description>
  </book>
  <book>
    <title>Waking Up</title>
    <author>Sam Harris</author>
    <description>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </description>
  </book>
</books>

Create a content type called book.

Save and add fields.

Add Author text field with the default settings:

Go to Structure > Feeds Importers > Add Importer.

Add Importer and name it as Book.

Basic Settings

Turn off periodic import:

Attach to content type setting allows us to import source when a specific type of node is created. With ‘Use standalone form’ we will have a form to import the data.

Note: remember to Save each section before you move to the next!

Fetcher

Select a File upload as the fetcher:

Leave File upload settings as they are:

Parser

Select XML Xpath as the parser:

Set the parser settings.

Values in the VALUE column has to match the names of the XML tags in the source file.

Define /books/book as the context:

Processor

Leave processor as node:

Select Bundle as Book.

Select Update existing nodes:

Use administer account for the Author:

Finally map the source data to the destination fields.

SOURCE column has the sources we defined previously and TARGET column describes the target fields in the Book content type.

Note: Make sure you define one target as unique!

Go to http://yoursite.com/import.

Select Book.

Upload the XML file and hit Import:

2 nodes will be created:

Update nodes

Change the data.xml file and upload it again:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<books>
  <book>
    <title>War and Peace</title>
    <author>Leo Tolstoi</author>
    <description>Lorem CHANGED DATA ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </description>
  </book>
  <book>
    <title>Waking Up</title>
    <author>Sam Harris</author>
    <description>Consectetur CHANGED DATA adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </description>
  </book>
  <book>
    <title>Hitch-22</title>
    <author>Christopher Hitchens</author>
    <description>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    </description>
  </book>
</books>

And we have 1 new node + 2 updated nodes: