class FeedsXPathParserXML in Feeds XPath Parser 7
Same name and namespace in other branches
- 6 FeedsXPathParserXML.inc \FeedsXPathParserXML
XPath parsing for XML.
Hierarchy
- class \FeedsXPathParserBase extends \FeedsParser
- class \FeedsXPathParserXML
Expanded class hierarchy of FeedsXPathParserXML
3 string references to 'FeedsXPathParserXML'
- FeedsXPathParserXMLTestCase::test in tests/
feeds_xpathparser_parser_xml.test - Run tests.
- FeedsXPathParserXMLTestCase::testVariables in tests/
feeds_xpathparser_parser_xml.test - Test variable substitution.
- feeds_xpathparser_feeds_plugins in ./
feeds_xpathparser.module - Implements hook_feeds_plugins().
File
- ./
FeedsXPathParserXML.inc, line 11 - s Contains FeedsXPathParserXML.
View source
class FeedsXPathParserXML extends FeedsXPathParserBase {
/**
* {@inheritdoc}
*/
protected function setup($source_config, FeedsFetcherResult $fetcher_result) {
if (!empty($source_config['exp']['tidy']) && extension_loaded('tidy')) {
$config = array(
'input-xml' => TRUE,
'wrap' => 0,
'tidy-mark' => FALSE,
);
// Default tidy encoding is UTF8.
$encoding = $source_config['exp']['tidy_encoding'];
$raw = tidy_repair_string($fetcher_result
->getRaw(), $config, $encoding);
}
else {
$raw = $fetcher_result
->getRaw();
}
$options = LIBXML_NONET;
$options |= defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0;
$options |= defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0;
$document = new DOMDocument();
$document->strictErrorChecking = FALSE;
$document->recover = TRUE;
$use = $this
->errorStart();
$success = $document
->loadXML($raw, $options);
$this
->errorStop($use, $source_config['exp']['errors']);
if (!$success) {
throw new Exception(t('There was an error parsing the XML document.'));
}
return $document;
}
/**
* {@inheritdoc}
*/
protected function getRaw(DOMNode $node) {
return $this->doc
->saveXML($node);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsXPathParserBase:: |
protected | property | The DOMDocument used for parsing. | |
FeedsXPathParserBase:: |
protected | property | The return value of libxml_disable_entity_loader(). | |
FeedsXPathParserBase:: |
protected | property | The elements that should be displayed in raw XML. | |
FeedsXPathParserBase:: |
protected | property | The DOMXPath objet used for parsing. | |
FeedsXPathParserBase:: |
public | function | Overrides parent::configDefaults(). | |
FeedsXPathParserBase:: |
public | function | Overrides parent::configForm(). | |
FeedsXPathParserBase:: |
public | function | Overrides parent::sourceFormValidate(). | |
FeedsXPathParserBase:: |
protected | function | Starts custom error handling. | |
FeedsXPathParserBase:: |
protected | function | Stops custom error handling. | |
FeedsXPathParserBase:: |
protected | function | Filters mappings, returning the ones that belong to us. | |
FeedsXPathParserBase:: |
public | function | Overrides parent::getMappingSources(). | |
FeedsXPathParserBase:: |
protected | function | Gets the mappings that are defined by this parser. | |
FeedsXPathParserBase:: |
protected | function | Gets the unique mappings targets that are used by this parser. | |
FeedsXPathParserBase:: |
public | function | Overrides parent::hasSourceConfig(). | |
FeedsXPathParserBase:: |
public | function | Implements FeedsParser::parse(). | |
FeedsXPathParserBase:: |
protected | function | Parses one item from the context array. | |
FeedsXPathParserBase:: |
public | function | Overrides parent::sourceDefaults(). | |
FeedsXPathParserBase:: |
public | function | Overrides parent::sourceForm(). | |
FeedsXPathParserBase:: |
public | function | Overrides parent::sourceFormValidate(). | |
FeedsXPathParserXML:: |
protected | function |
Helper callback to return the raw value. Overrides FeedsXPathParserBase:: |
|
FeedsXPathParserXML:: |
protected | function |
Classes that use FeedsXPathParserBase must implement this. Overrides FeedsXPathParserBase:: |