Skip to content

Error with addHtml() and "&" #406

@skurty

Description

@skurty

Hi,

I'm trying to create a doc:

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $content);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('...');

where $content contains a string with a "&".

I get this error:

Warning: DOMDocument::loadXML(): xmlParseEntityRef: no name in Entity, line: 1 in PhpOffice/PhpWord/Shared/Html.php on line 55
Notice: Trying to get property of non-object in PhpOffice/PhpWord/Shared/Html.php on line 129
Notice: Trying to get property of non-object in PhpOffice/PhpWord/Shared/Html.php on line 169
Notice: Trying to get property of non-object in PhpOffice/PhpWord/Shared/Html.php on line 170

I've tried to replace the & by & but same error. If I remove it, no problem.

I'm using the last version of PHPWord.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions