class FeedsExHtml in Feeds extensible parsers 7
Same name and namespace in other branches
- 7.2 src/FeedsExHtml.inc \FeedsExHtml
Parses HTML documents with XPath.
Hierarchy
- class \FeedsExBase extends \FeedsParser
- class \FeedsExXml
- class \FeedsExHtml
- class \FeedsExXml
Expanded class hierarchy of FeedsExHtml
2 string references to 'FeedsExHtml'
- FeedsExHtmlTests::setUp in src/
Tests/ FeedsExHtml.test - feeds_ex_feeds_plugins in ./
feeds_ex.feeds.inc - Implements hook_feeds_plugins().
File
- src/
FeedsExHtml.inc, line 11 - Contains FeedsExHtml.
View source
class FeedsExHtml extends FeedsExXml {
/**
* Whether this version of PHP has the correct saveHTML() method.
*
* @var bool
*/
protected $useSaveHTML;
/**
* {@inheritdoc}
*/
protected $encoderClass = 'FeedsExHtmlEncoder';
/**
* {@inheritdoc}
*/
public function __construct($id) {
parent::__construct($id);
// DOMDocument::saveHTML() cannot take $node as an argument prior to 5.3.6.
$this->useSaveHTML = version_compare(PHP_VERSION, '5.3.6', '>=');
}
/**
* {@inheritdoc}
*/
protected function prepareDocument(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
$raw = $this
->prepareRaw($fetcher_result);
if ($this->config['use_tidy'] && extension_loaded('tidy')) {
$raw = tidy_repair_string($raw, $this
->getTidyConfig(), 'utf8');
}
return FeedsExXmlUtility::createHtmlDocument($raw);
}
/**
* {@inheritdoc}
*/
protected function getRaw(DOMNode $node) {
if ($this->useSaveHTML) {
return $node->ownerDocument
->saveHTML($node);
}
return $node->ownerDocument
->saveXML($node, LIBXML_NOEMPTYTAG);
}
/**
* {@inheritdoc}
*/
protected function getTidyConfig() {
return array(
'merge-divs' => FALSE,
'merge-spans' => FALSE,
'join-styles' => FALSE,
'drop-empty-paras' => FALSE,
'wrap' => 0,
'tidy-mark' => FALSE,
'escape-cdata' => TRUE,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsExBase:: |
protected | property | The encoder used to convert encodings. | |
FeedsExBase:: |
protected | property | The object used to display messages to the user. | |
FeedsExBase:: |
protected | function | Renders our debug messages into a list. | |
FeedsExBase:: |
protected | function | Executes the source expressions. | |
FeedsExBase:: |
public | function | Returns the encoder. | |
FeedsExBase:: |
protected | function | Returns the configuration form table header. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | Returns the messenger. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Returns whether or not this parser uses a context query. | 2 |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Loads the necessary library. | 2 |
FeedsExBase:: |
protected | function | Logs errors. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
protected | function | Performs the actual parsing. | 2 |
FeedsExBase:: |
protected | function | Prepares the expressions for parsing. | |
FeedsExBase:: |
protected | function | Prepares the raw string for parsing. | |
FeedsExBase:: |
protected | function | Prepares the variable map used to substitution. | |
FeedsExBase:: |
protected | function | Prints errors to the screen. | |
FeedsExBase:: |
public | function | Sets the encoder. | |
FeedsExBase:: |
public | function | Sets the messenger to be used to display messages. | |
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExBase:: |
public | function | ||
FeedsExHtml:: |
protected | property |
The class used as the text encoder. Overrides FeedsExXml:: |
|
FeedsExHtml:: |
protected | property | Whether this version of PHP has the correct saveHTML() method. | |
FeedsExHtml:: |
protected | function |
Returns the raw XML of a DOM node. Overrides FeedsExXml:: |
|
FeedsExHtml:: |
protected | function |
Returns the options for phptidy. Overrides FeedsExXml:: |
|
FeedsExHtml:: |
protected | function |
Prepares the DOM document. Overrides FeedsExXml:: |
|
FeedsExHtml:: |
public | function | ||
FeedsExXml:: |
protected | property | The previous value for the entity loader. | |
FeedsExXml:: |
protected | property | The previous value for XML error handling. | |
FeedsExXml:: |
protected | property | The FeedsExXpathDomXpath object used for parsing. | |
FeedsExXml:: |
protected | function |
Allows subclasses to cleanup after parsing. Overrides FeedsExBase:: |
|
FeedsExXml:: |
public | function |
Overrides FeedsExBase:: |
|
FeedsExXml:: |
public | function |
Overrides FeedsExBase:: |
|
FeedsExXml:: |
protected | function |
Returns a form element for a specific column. Overrides FeedsExBase:: |
1 |
FeedsExXml:: |
protected | function |
Reuturns the list of table headers. Overrides FeedsExBase:: |
1 |
FeedsExXml:: |
public | function |
Overrides FeedsExBase:: |
|
FeedsExXml:: |
protected | function |
Returns rows to be parsed. Overrides FeedsExBase:: |
1 |
FeedsExXml:: |
protected | function |
Executes a single source expression. Overrides FeedsExBase:: |
1 |
FeedsExXml:: |
protected | function |
Returns the errors after parsing. Overrides FeedsExBase:: |
|
FeedsExXml:: |
protected | function | Returns the inner XML of a DOM node. | |
FeedsExXml:: |
protected | function |
Allows subclasses to prepare for parsing. Overrides FeedsExBase:: |
1 |
FeedsExXml:: |
protected | function |
Starts internal error handling. Overrides FeedsExBase:: |
|
FeedsExXml:: |
protected | function |
Stops internal error handling. Overrides FeedsExBase:: |
|
FeedsExXml:: |
protected | function |
Validates an expression. Overrides FeedsExBase:: |
1 |