3

I've installed XPath/Feeds/D7, but I don't know how to configure XPath parser settings.

Maybe someone can help me to set it right.

I just want to inject <title> and <text xml:space="preserve"> to my node.

I need help to configure my XPath Parser settings : admin/structure/feeds/edit/my_import/settings/FeedsXPathParserXML

I've the following XML structure :

<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="fr">
  <siteinfo>
    <sitename>Site Name</sitename>
    <base>http://domain.net/index.php/StartPage</base>
    <generator>MediaWiki 1.15.5-1~bpo50+1</generator>
    <case>first-letter</case>
    <namespaces>
      <namespace key="-2">Media</namespace>
      <namespace key="-1">Special</namespace>
      <namespace key="0" />
      <namespace key="1">Chat</namespace>
      <namespace key="2">user</namespace>
      <namespace key="3">Chat user</namespace>
      <namespace key="4">domain.net</namespace>
      <namespace key="5">Chat domain.net</namespace>
      <namespace key="6">files</namespace>
      <namespace key="7">Chat files</namespace>
      <namespace key="8">MediaWiki</namespace>
      <namespace key="9">Chat MediaWiki</namespace>
      <namespace key="10">Model</namespace>
      <namespace key="11">Chat model</namespace>
      <namespace key="12">help</namespace>
      <namespace key="13">Chat help</namespace>
      <namespace key="14">category</namespace>
      <namespace key="15">Chat category</namespace>
    </namespaces>
  </siteinfo>
  <page>
    <title>Drush</title>
    <id>579</id>
    <revision>
      <id>1637</id>
      <timestamp>2012-05-25T14:51:51Z</timestamp>
      <contributor>
        <username>admin</username>
        <id>1</id>
      </contributor>
      <comment>/* Install Drupal with Drush */</comment>
      <text xml:space="preserve">Drush is a command line utility.

=Install Drupal with Drush=
To install drupal with drush :
 drush site-install standard --db-url=mysql://username:pass@localhost/databasename

[[category:Drupal]]</text>
    </revision>
  </page>
  <page>
    <title>Memcache</title>
    <id>586</id>
    <revision>
      <id>1287</id>
      <timestamp>2012-02-12T17:43:32Z</timestamp>
      <contributor>
        <username>admin</username>
        <id>1</id>
      </contributor>
      <comment>Do it under Debian</comment>
      <text xml:space="preserve">=Install=
==Debian==
===Memcache Server===
To install :
 aptitude install memcached

Read and change ''/etc/memcached.conf''.
===PHP5 / PECL===
Install memcache PECL :
 php5-memcache
or
 pecl install memcache

Restart Apache.

===Drupal===
* InstallMemcache module in Drupal.
* Change ''settings.php'' :
&lt;source lang=&quot;php&quot;&gt;
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'site_prefix';
&lt;/source&gt;

Read : http://drupal.org/node/1131458


[[category:Linux]]

[[category:Drupal]]</text>
    </revision>
  </page>
</mediawiki>

Optional task : How can I convert "=" to <h1>, "==" to <h2>, space before start of line to <pre>, [[category:xyz]] to Tags, etc ... ?

  • While I understand that you are doing this within the context of a Drupal module, your question is really about XPath, and has nothing to do with Drupal. I call off-topic. Your "optional task" however, should be opened as a separate question. I could actually write up something on that myself. I'll try and find the time for that later. :) – Letharion May 29 '12 at 8:30
  • I don't completely agree, as the Feeds module has its own logic on top of XPath, so perhaps it's borderline, but maybe not OT. As for the optional task, Feeds Tamper could probably be of use. – Countzero May 29 '12 at 10:03
  • @Countzero : Thank you, I'll gonna test Feeds Tamper. – user117283 Jun 1 '12 at 20:21
7

Context should be : //Mediawiki/page, Title field should be title and Text should be revision/text.

  • It work great, thank you !! I think it can help everyone who want to import XML content to Drupal. – user117283 Jun 1 '12 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.