title: Laravel - DOMDocument::loadXML(): Opening and ending tag mismatch - PhpWord error
body: <p>I have 3 Blade files that are written in HTML, I am currently using WKHTMLTOPDF to export them to a PDF format, I now want to export the same HTML files to a Word Document.</p>
  
  <p>So far, the best package for Laravel I can find is <a href="https://github.com/PHPOffice/PHPWord" rel="nofollow">PhpWord</a>.</p>
  
  <p>Snippet of code:</p>
  
  <pre><code>&lt;div class="page-break"&gt;&lt;/div&gt;
  
  &lt;h3&gt;Introduction&lt;/h3&gt;
  
  &lt;p&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;/p&gt;
  </code></pre>
  
  <p>My code so far:</p>
  
  <pre><code>$phpWord = new \PhpOffice\PhpWord\PhpWord();
  $section = $phpWord-&gt;addSection();    
  $report = view('reports.audit-report', $data)-&gt;render();
  
  \PhpOffice\PhpWord\Shared\Html::addHtml($section, $report, true);
  
  $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
  $objWriter-&gt;save('helloWorld.docx');
  </code></pre>
  
  <p>It is currently returning this error:</p>
  
  <blockquote>
    <p>DOMDocument::loadXML(): Opening and ending tag mismatch: link line 1
    and div in Entity, line: 1</p>
  </blockquote>
  
  <p>The annoying thing is, is that no matter what line(s) I remove, that error always persists, until I remove literally every line of HTML! </p>
  
  <p>I can prevent this error from happening by using the following code:</p>
  
  <pre><code>libxml_use_internal_errors(true);
  </code></pre>
  
  <p>However then, it returns:</p>
  
  <blockquote>
    <p>ErrorException in Html.php line 136: Trying to get property of non-object</p>
  </blockquote>
  
  <p>Has anybody successfully resolved these errors before? If you require any more code, please just let me know. Many thanks.</p>