You are here

public static function HttpHelpers::findRelationFromXml in Feeds 8.3

Finds a link relation in XML.

Parameters

string $xml: The XML.

string $relation: The relation to find.

Return value

string|false The relation, or false.

2 calls to HttpHelpers::findRelationFromXml()
HttpHelpersTest::testFindLinkXml in tests/src/Unit/Component/HttpHelpersTest.php
@covers ::findRelationFromXml
PubSubHubbub::findRelation in src/EventSubscriber/PubSubHubbub.php
Finds a hub from a fetcher result.

File

src/Component/HttpHelpers.php, line 88

Class

HttpHelpers
Various helpers for dealing with HTTP data.

Namespace

Drupal\feeds\Component

Code

public static function findRelationFromXml($xml, $relation) {

  // Check if $xml has length.
  if (!isset($xml[0])) {
    return FALSE;
  }
  $document = static::getDomDocument($xml);
  $xpath = new \DOMXPath($document);
  $list = $xpath
    ->query('//*[local-name() = "link" and @rel = "' . $relation . '"]/@href');
  if ($list->length === 0) {
    return FALSE;
  }
  return $list
    ->item(0)->value;
}