PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.25k stars 2.69k forks source link

the name in the end tag of the element must match the element type in the start tag #1218

Closed luisorozcomlv closed 6 years ago

luisorozcomlv commented 6 years ago

sorry, this is my first post on githb...

Expected Behavior

Create a new document from another docx file using template processor

Current Behavior

working fine, no error reportes durning script execution

Failure Information

When i try to open the result docx file i got this error:

the name in the end tag of the element must match the element type in the start tag:

Location: Part: /word/document.xml Line 2: Column:

How to Reproduce

$template = new \PhpOffice\PhpWord\TemplateProcessor("dictamTpl.docx");

foreach($onlyOneRow as $n => $c) {

$c = xmlEntities($c); $template->setValue($n, $c); $template->setValue(strtoupper($n), $c); }

$template->saveAs('result.docx');

Context

luisorozcomlv commented 6 years ago

I tried without any setValue, only reading and saving the document, but still got the same error.

troosan commented 6 years ago

@luisorozcomlv can you share the document (or any other document) that makes this fail?

luisorozcomlv commented 6 years ago

https://www.mlv.com.mx/downloads/Archive.zip

troosan commented 6 years ago

@luisorozcomlv I don't know if that's the cause of the issue but if you check the source (rename to dictamTpl.zip and unzip) you will see that the ${acciondenominada}, ${fechajuntaaclaratotia}, ... are split over multiple xml nodes. This causes the replacement to fail. Fix this in the source document I'm pretty sure it will be OK.

luisorozcomlv commented 6 years ago

It works!. Thank you. BTW, i also change the isolated $ chars to it html entity.