FluidXml\FluidHelper::simplexmlToStringWithoutHeaders PHP Method

simplexmlToStringWithoutHeaders() public static method

public static simplexmlToStringWithoutHeaders ( SimpleXMLElement $element, $html = false )
$element SimpleXMLElement
    public static function simplexmlToStringWithoutHeaders(\SimpleXMLElement $element, $html = false)
    {
        $dom = \dom_import_simplexml($element);
        return static::exportNode($dom->ownerDocument, $dom, $html);
    }

Usage Example

Beispiel #1
0
            \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 () {
        $hml = new FluidXml(['html' => ['body' => ['div' => ['p' => ['@class' => 'a', '@id' => '123', ['span']], 'h1' => ['@class' => 'b'], 'p' => ['@class' => 'a b'], 'p' => ['@class' => 'a']]]]]);
        $hml->namespace('svg', 'http://svg.org');
        $hml->query('//body')->add('svg', true)->add('shape');
        it('should support the CSS selector A', function () use($hml) {
            $actual = $hml->query('p')->array();
            $expected = $hml->query('.//p')->array();
            \assert($actual === $expected, __($actual, $expected));
            $expected = $hml->query('//p')->array();