FluidXml\FluidHelper::domnodelistToString PHP Метод

domnodelistToString() публичный статический Метод

public static domnodelistToString ( DOMNodeList $nodelist, $html = false )
$nodelist DOMNodeList
    public static function domnodelistToString(\DOMNodeList $nodelist, $html = false)
    {
        $nodes = [];
        // Algorithm 1:
        foreach ($nodelist as $n) {
            $nodes[] = $n;
        }
        // Algorithm 2:
        // $nodes = \iterator_to_array($nodelist);
        // Algorithm 1 is faster than Algorithm 2.
        return static::domnodesToString($nodes, $html);
    }

Usage Example

Пример #1
0
     it('should convert a DOMDocument instance to an XML string without the XML headers (declaration and stylesheets)', function () {
         $xml = new FluidXml();
         $actual = FluidHelper::domdocumentToStringWithoutHeaders($xml->dom());
         $expected = "<doc/>";
         \assert($actual === $expected, __($actual, $expected));
         $xml = new FluidXml('doc', ['stylesheet' => 'x.com/style.xsl']);
         $actual = FluidHelper::domdocumentToStringWithoutHeaders($xml->dom());
         $expected = "<doc/>";
         \assert($actual === $expected, __($actual, $expected));
     });
 });
 describe(':domnodelistToString()', function () {
     it('should convert a DOMNodeList instance to an XML string', function () {
         $xml = new FluidXml();
         $nodes = $xml->dom()->childNodes;
         $actual = FluidHelper::domnodelistToString($nodes);
         $expected = "<doc/>";
         \assert($actual === $expected, __($actual, $expected));
     });
 });
 describe(':domnodesToString()', function () {
     it('should convert an array of DOMNode instances to an XML string', function () {
         $xml = new FluidXml();
         $nodes = [$xml->dom()->documentElement];
         $actual = FluidHelper::domnodesToString($nodes);
         $expected = "<doc/>";
         \assert($actual === $expected, __($actual, $expected));
     });
 });
 describe('simplexmlToStringWithoutHeaders()', function () {
     it('should convert a SimpleXMLElement instance to an XML string without the XML headers (declaration and stylesheets)', function () {