Skip to content

DOMElement::getAttribute() expects parameter 1 to be string, array given #1369

Closed
@ikraddy

Description

@ikraddy

This is:

I don't know how to read the docx file. I tried to read a docx file that I created, but I made a mistake.

How can I read the text and picture information in the docx file correctly?

<?php
$filename = 'D:\projects/web/mydoc.docx';
$fh = IOFactory::load($filename);

Context

  • PHP version: 7.1.13
  • PHPWord version: 0.14
Error:
Warning: DOMElement::getAttribute() expects parameter 1 to be string, array given in D:\projects\www\test\phpword\vendor\phpoffice\common\src\Common\XMLReader.php on line 140

Fatal error: Uncaught InvalidArgumentException: is not a valid value for PhpOffice\PhpWord\SimpleType\DocProtect, possible values are none, readOnly, comments, trackedChanges, forms in D:\projects\www\test\phpword\src\PhpWord\Shared\AbstractEnum.php:72 Stack trace: 
#0 D:\projects\www\test\phpword\src\PhpWord\Metadata\Protection.php(97): PhpOffice\PhpWord\Shared\AbstractEnum::validate(NULL) 
#1 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007\Settings.php(112): PhpOffice\PhpWord\Metadata\Protection->setEditing(NULL) 
#2 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007\Settings.php(71): PhpOffice\PhpWord\Reader\Word2007\Settings->setDocumentProtection(Object(PhpOffice\Common\XMLReader), Object(PhpOffice\PhpWord\PhpWord), Object(DOMElement)) 
#3 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007.php(94): PhpOffice\PhpWord\Reader\Word2007\Settings->read(Object(PhpOffice\PhpWord\PhpWord)) 
#4 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007.php(70): PhpOffice\PhpWord\Reader\Word2007->readPart(Object( in D:\projects\www\test\phpword\src\PhpWord\Shared\AbstractEnum.php on line 72

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions