[development] Simple XML Import
fletch at splendora.com
Wed Jan 3 20:05:36 UTC 2007
I created a quick XML import method and I'm wondering if others are
interested in it.
This thing defines a simple XML format with tags: drupal (doc element),
vocab, term, user, node, comment. It imports each of these things by
calling the relevant xxx_save() function. Each of those tags can define
a "fields" child element. The children of <fields> are turned into
object, array, or primitive values and passed to the save func. Node
elements located inside term elements are categorized by that term.
The system holds a legacy ID which is mapped to a Drupal ID. It is used
to ensure a piece of content is not imported multiple times. Therefore,
an XML document can be updated and imported again without causing dupes.
The system can also use this ID to reference existing content, for
example in a uid field or the taxonomy array.
Since it's just calling node_save to do all the work, this system can
import custom node types simply by providing the right 'type' field in a
node element and providing the fields that the custom node module
expects. I have imported 5 different content types using this method: a
custom review type, polls, blog (converted the mt2drupal script to this
XML format), a custom newsletter type, and galleries.
I of course know about Jaza's work on import/export API but it seemed
like an overkill solution to me and I didn't want to really learn an
API. I just wanted a quick XML format to do some dirty work which I
tried to do by hand on the first rev. The XML format mainly allows me to
inspect the data before I run the import.
So my question for you, fellow Drupallers, is does this sound useful to
you? Would it be worth my time turning this thing into a real module?
Currently it's a command-line hack that lives in Drupal root directory
and bootstraps. It would be neat if there was a module page, an upload
form, and perhaps some support functions for creating the XML format
More information about the development