FluidXml\FluidHelper::domnodesToString PHP Method

domnodesToString() public static method

public static domnodesToString ( array $nodes, $html = false )
$nodes array
    public static function domnodesToString(array $nodes, $html = false)
    {
        $dom = $nodes[0]->ownerDocument;
        $xml = '';
        foreach ($nodes as $n) {
            $xml .= static::exportNode($dom, $n, $html) . PHP_EOL;
        }
        return \rtrim($xml);
    }

Usage Example

Esempio n. 1
0
        });
    });
    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 () {
            $xml = \simplexml_import_dom((new FluidXml())->dom());
            $actual = FluidHelper::simplexmlToStringWithoutHeaders($xml);
            $expected = "<doc/>";
            \assert($actual === $expected, __($actual, $expected));
        });
    });
});
describe('CssTranslator', function () {
    describe('.xpath()', function () {