Forum


Replies: 3   Views: 1306
"domdocument::loadxml(): empty string supplied as input" after create document from template
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 31-07-2018 - 08:22

Hello,

That line (877), includes the following lines:

$documentCoreContent = $this->docxStructure->getContent('docProps/core.xml');

$tags = '';

$xmlCoreContent = new \DOMDocument();
$xmlCoreContent->loadXML($documentCoreContent);

It gets the docProps/core.xml file, that is a required file for a DOCX document.  Maybe your DOCX doesn't include that file?

What program did you use to generate the DOCX you are trying to transform?

Please also try to run the included samples in the examples folder.

If your DOCX doesn't include that file (although it should), please edit the TransformDocAdvHTML.php to check if the content exists:

protected function getMetaValues()
{
    $documentCoreContent = $this->docxStructure->getContent('docProps/core.xml');

    $tags = '';

    if ($documentCoreContent) {
        $xmlCoreContent = new \DOMDocument();
        $xmlCoreContent->loadXML($documentCoreContent);
        foreach ($xmlCoreContent->childNodes->item(0)->childNodes as $prop) {
            switch ($prop->tagName) {
                case 'dc:title':
                    $tags .= '<title>' . $prop->nodeValue . '</title>';
                    break;
                case 'dc:creator':
                    $tags .= '<meta name="author" content="' . $prop->nodeValue . '">';
                    break;
                case 'cp:keywords':
                    $tags .= '<meta name="keywords" content="' . $prop->nodeValue . '">';
                    break;
                case 'dc:description':
                    $tags .= '<meta name="description" content="' . $prop->nodeValue . '">';
                    break;
                default:
                    break;
            }
        }
    }

    return $tags;
}

We move your issue to the dev team to test if this check need to be added to the stable package.

Regards.