You are here

protected function FeedsExXml::prepareDocument in Feeds extensible parsers 7.2

Same name and namespace in other branches
  1. 7 src/FeedsExXml.inc \FeedsExXml::prepareDocument()

Prepares the DOM document.

Parameters

FeedsSource $source: The feed source.

FeedsFetcherResult $fetcher_result: The fetcher result.

Return value

DOMDocument The DOM document.

2 calls to FeedsExXml::prepareDocument()
FeedsExQueryPathXml::executeContext in src/FeedsExQueryPathXml.inc
Returns rows to be parsed.
FeedsExXml::setUp in src/FeedsExXml.inc
Allows subclasses to prepare for parsing.
2 methods override FeedsExXml::prepareDocument()
FeedsExHtml::prepareDocument in src/FeedsExHtml.inc
Prepares the DOM document.
FeedsExQueryPathHtml::prepareDocument in src/FeedsExQueryPathHtml.inc
Prepares the DOM document.

File

src/FeedsExXml.inc, line 222
Contains FeedsExXml.

Class

FeedsExXml
Parses XML documents with XPath.

Code

protected function prepareDocument(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $raw = trim($fetcher_result
    ->getRaw());
  if (!strlen($raw)) {
    throw new FeedsExEmptyException();
  }
  $raw = $this
    ->convertEncoding($raw);

  // Remove default namespaces. This has to run after the encoding conversion
  // because a limited set of encodings are supported in regular expressions.
  $raw = FeedsExXmlUtility::removeDefaultNamespaces($raw);
  if ($this->config['use_tidy'] && extension_loaded('tidy')) {
    $raw = tidy_repair_string($raw, $this
      ->getTidyConfig(), 'utf8');
  }
  return FeedsExXmlUtility::createXmlDocument($raw);
}