class XPathXMLParser in Feeds XPath Parser 8
Defines an XML feed parser.
Plugin annotation
@Plugin(
id = "feeds_xpathparser_xml",
title = @Translation("XPath XML parser"),
description = @Translation("Parse XML files using XPath.")
)
Hierarchy
- class \Drupal\feeds_xpathparser\ParserBase extends \Drupal\feeds\Plugin\ParserBase implements \Drupal\feeds\FeedPluginFormInterface, FormInterface
- class \Drupal\feeds_xpathparser\Plugin\feeds\Parser\XPathXMLParser
Expanded class hierarchy of XPathXMLParser
File
- lib/
Drupal/ feeds_xpathparser/ Plugin/ feeds/ Parser/ XPathXMLParser.php, line 24 - Contains \Drupal\feeds_xpathparser\Plugin\feeds\Parser\XPathXMLParser.
Namespace
Drupal\feeds_xpathparser\Plugin\feeds\ParserView source
class XPathXMLParser extends ParserBase {
/**
* {@inheritdoc}
*/
protected function setup(array $feed_config, FetcherResultInterface $fetcher_result) {
if (!empty($feed_config['tidy'])) {
$config = array(
'input-xml' => TRUE,
'wrap' => 0,
'tidy-mark' => FALSE,
);
// Default tidy encoding is UTF8.
$encoding = $feed_config['tidy_encoding'];
$raw = tidy_repair_string(trim($fetcher_result
->getRaw()), $config, $encoding);
}
else {
$raw = $fetcher_result
->getRaw();
}
$doc = new \DOMDocument();
$use = $this
->errorStart();
$success = $doc
->loadXML($raw);
unset($raw);
$this
->errorStop($use, $feed_config['errors']);
if (!$success) {
throw new \RuntimeException(t('There was an error parsing the XML document.'));
}
return $doc;
}
/**
* {@inheritdoc}
*/
protected function getRaw(\DOMNode $node) {
return $this->doc
->saveXML($node);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormInterface:: |
public | function | Returns a unique string identifying the form. | 236 |
FormInterface:: |
public | function | Form submission handler. | 192 |
ParserBase:: |
protected | property | The DOMDocument to parse. | |
ParserBase:: |
protected | property | The mappings to return raw XML for. | |
ParserBase:: |
protected | property | The DOMXpath object to use for XPath queries. | |
ParserBase:: |
protected | function | ||
ParserBase:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
ParserBase:: |
public | function | ||
ParserBase:: |
protected | function | Starts custom error handling. | |
ParserBase:: |
protected | function | Stops custom error handling. | |
ParserBase:: |
public | function | ||
ParserBase:: |
public | function | Overrides parent::feedFormValidate(). | |
ParserBase:: |
protected | function | Filters mappings, returning the ones that belong to us. | |
ParserBase:: |
public | function | ||
ParserBase:: |
protected | function | Gets the mappings that are defined by this parser. | |
ParserBase:: |
protected | function | Gets the unique mappings targets that are used by this parser. | |
ParserBase:: |
protected | function | Recursivly sorts an array. | |
ParserBase:: |
public | function | ||
ParserBase:: |
protected | function | Parses one item from the context array. | |
ParserBase:: |
public | function | ||
ParserBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
|
XPathXMLParser:: |
protected | function |
Returns the raw node value. Overrides ParserBase:: |
|
XPathXMLParser:: |
protected | function |
Classes that use ParserBase must implement this. Overrides ParserBase:: |