I use the Symfony DOM Crawler to read and save an HTML document containing a template. But the closing HTML tags are missing in the template. Here is an example:
<?php
$htmlString = <<<'HTML'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Title</h1>
<script id="my-template" type="text/template">
<div>{{ Name }}</div>
</script>
</body>
HTML;
$crawler = new Crawler($htmlString);
$output = join(
$crawler->filterXPath('//body')->each(
function (Crawler $node, $i) use ($htmlString) {
return $node->html();
}
)
);
I would expect something like:
<h1>Title</h1>
<script id="my-template" type="text/template">
<p>Hello</p>
<div>{{ Name }}</div>
</script>
But I get:
<h1>Title</h1>
<script id="my-template" type="text/template">
<p>Hello
<div>{{ Name }}
</script>
Do you have an any idea why is the DOM Crawler omitting the closing tag?