FeedAPI is an excellent module to deliver information from the outside world into a Drupal installation. Currently FeedAPI supports to import RSS nodes, which include most applications. But legacy systems (which are probably 3 to 7 years old) and most enterprise information systems have no RSS output that supports only a few fields as a content type. In such an occasion, a more generic format is required to feed data into Drupal with FeedAPI. One of the best practices is to acquire information from legacy systems in XML format that is supported by a FeedAPI’s parser (which is already described in the previous post). Although any format is parsable, XML is more intuitive.
Generally speaking, FeedAPI accepts a list of items that are described in the same format. To generalize FeedAPI usage of feeds, a simple XML format is proposed:
<?xml version="1.0" encoding="utf-8"?>
id="an id for a feed" title="the title for a feed"
description="the description for this feed"
link="the link to be imported as the original_url, can be ignored">
<node id="a unique id" title="the title to be imported as the node title"
description="the description to be imported as the node description"
link="the link to be imported as the original_url, which can be ignored">
<foo:last-name>foo's last name</foo:last-name>
In the above example, a simple XML wrapper is used to encasulate the actual data (foo’s item description). Foo’s original XML elements an be directly ecansulated into the data field with proper namespace settings.
This element has four attributes, including
id is a unique identification string in a drupal installation, it is imported into drupal as the
description are respectively title and description in a FeedAPI feed. When a feed in the above format is imported, these two fields are imported as the feed’s title and description.
link is imported as the
original_url field for a FeedAPI feed. In current implementation,
original_url must have at least one exist. In my SimpleXML parser implementation,
id attribute) is required.
feed tag consists of a series of
node tag is a container for a node’s details. Currently only
data tag is allowed under
node tag. Other tags can also be added under
node to specify any node information.
node has also the four attributes that are described in
feed to represent drupal-specific meta data.
data tag is a container of the original data that is converted (or directly copied) from an original XML. A namespace is suggested to indicate the source of the data. Any XML data can be added under
data tag, however, the format must be consistent so the parser is able to get the same set of information for each node.