Projet

Général

Profil

Paste
Télécharger (1,06 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds_xpathparser / feeds_xpathparser.api.php @ f066bdb5

1
<?php
2

    
3
/**
4
 * @file
5
 * Documentation of Feeds XPath Parser hooks.
6
 */
7

    
8
/**
9
 * Implements hook_feeds_xpathparser_filter_domnode().
10
 *
11
 * Allows arbitrary manipulation of the feed item being processed while it is
12
 * still a DOMNode.
13
 *
14
 * This hook can also be used to skip parsing of a specific feed item by
15
 * returning TRUE.
16
 *
17
 * @param DOMNode $node
18
 *   The feed item being parsed, as a dom node.
19
 * @param DOMDocument $document
20
 *   The entire XML/HTML document being parsed.
21
 * @param FeedsSource $source
22
 *   The feed source being imported.
23
 *
24
 * @return bool
25
 *   Returns TRUE if the dom node should be skipped.
26
 */
27
function hook_feeds_xpathparser_filter_domnode(DOMNode $node, DOMDocument $document, FeedsSource $source) {
28

    
29
  if (my_module_node_is_bad($node)) {
30
    return TRUE;
31
  }
32

    
33
  // To print out the raw XML.
34
  $debug = $document->saveXML($node);
35

    
36
  // For HTML.
37
  if (version_compare(phpversion(), '5.3.6', '>=')) {
38
    $debug = $document->saveHTML($node);
39
  }
40
  else {
41
    $debug = $document->saveXML($node, LIBXML_NOEMPTYTAG);
42
  }
43

    
44
  drupal_set_message($debug);
45
}