I used the information from...

http://drupal.org/node/622700

To write a small custom module that provides a custom parser using Simplepie. I modified the code to look like the code below.

The code was taken from the examples from The developer's guide to Feeds.

Everything seems to work fine since I can see my Custom Parser under the Feeds UI and it also displays the custom elements under the mapping section.

But when I for example map one of the custom fields/elements to the Title or Body for example the data seems to be empty.

Am I being daft here? My skills as a coder is mediocre at best...

/**
* A simple parser that extends FeedsSimplePieParser by adding support for a
* couple of Custom Namespace tags.
*/
class MyParser extends FeedsSimplePieParser {
  /**
   * Add the extra mapping sources provided by this parser.
   */
  public function getMappingSources() {
    return parent::getMappingSources() + array(
      'g_zoning' => array(
        'name' => t('g:zoning'),
        'description' => t('Zoning.'),
      ),
      'g_id' => array(
        'name' => t('g:id'),
        'description' => t('ID'),
      ),
      'c_property_id' => array(
        'name' => t('c:property_id'),
        'description' => t('Property ID.'),
      ),
    );
  }

  /**
   * Parse the extra mapping sources provided by this parser.
   */
  protected function parseExtensions(&$item, $simplepie_item) {
    $google_namespace = 'http://base.google.com/ns/1.0';
    $custom_namespace = 'http://base.google.com/cns/1.0';
    if ($value = $simplepie_item->get_item_tags($google_namespace, 'zoning')) {
      $item['g_zoning'] = $value[0]['data'];
    }
    if ($value = $simplepie_item->get_item_tags($custom_namespace, 'property_id')) {
      $item['c_property_id'] = $value[0]['data'];
    }
    if ($value = $simplepie_item->get_item_tags($google_namespace, 'id')) {
      $item['g_id'] = $value[0]['data'];
    }
  }
}

I must also mention that this behavior seems manifests itself when I'm using the Google Base Namespaces...

Any information would be greatly appreciated...

Comments

alex_b’s picture

Feeds wise this code looks good. Are you sure that your parsing code actually yields the elements as expected? I. e. if you dump $item at the end of parseExtensions() to the screen, can you see the values as expected?

alex_b’s picture

Status: Active » Closed (fixed)

Closing support request after multiple weeks of inactivity.