You are here

protected function InstallableLibrary::requestXml in Markdown 8.2

Retrieves XML from a URL.

@noinspection PhpComposerExtensionStubsInspection @sse https://git.drupalcode.org/project/drupal/-/blob/5c4e2e76a1c7972c4b03496...

Parameters

string $url: The URL where to retrieve JSON from.

bool $array: Flag indicating whether to return an array or a DOM object.

Return value

\DOMDocument|array|void A DOMDocument or array (if $array is specified) of XML if successful, NULL otherwise.

2 calls to InstallableLibrary::requestXml()
PeclExtension::getAvailableVersions in src/Annotation/PeclExtension.php
Retrieves the available versions of the library.
PeclExtension::getPackageInfo in src/Annotation/PeclExtension.php
Retrieves the package information for the PECL package.

File

src/Annotation/InstallableLibrary.php, line 538

Class

InstallableLibrary

Namespace

Drupal\markdown\Annotation

Code

protected function requestXml($url, $array = FALSE) {
  $response = $this
    ->request($url);
  $statusCode = $response
    ->getStatusCode();
  if ($statusCode >= 200 && $statusCode < 400 && ($contents = $response
    ->getContent())) {
    if ($array) {
      return (array) json_decode(json_encode(simplexml_load_string($contents)), TRUE);
    }
    elseif (($dom = new \DOMDocument()) && $dom
      ->loadXML($contents)) {
      return $dom;
    }
  }
}