Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DOMNodeComparator.php

function DOMNodeComparator::nodeToText

Returns the normalized, whitespace-cleaned, and indented textual representation of a DOMNode.

1 call to DOMNodeComparator::nodeToText()
DOMNodeComparator::assertEquals in vendor/sebastian/comparator/src/DOMNodeComparator.php

File

vendor/sebastian/comparator/src/DOMNodeComparator.php, line 54

Class

DOMNodeComparator

Namespace

SebastianBergmann\Comparator

Code

private function nodeToText(DOMNode $node, bool $canonicalize, bool $ignoreCase) : string {
    if ($canonicalize) {
        $document = new DOMDocument();
        try {
            $c14n = $node->C14N();
            assert(!empty($c14n));
            @$document->loadXML($c14n);
        } catch (ValueError) {
        }
        $node = $document;
    }
    $document = $node instanceof DOMDocument ? $node : $node->ownerDocument;
    $document->formatOutput = true;
    $document->normalizeDocument();
    $text = $node instanceof DOMDocument ? $node->saveXML() : $document->saveXML($node);
    return $ignoreCase ? mb_strtolower($text, 'UTF-8') : $text;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal