Replies: 2   Views: 1091
Consistent way to read list variables
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  · 23-06-2020 - 14:47


The getTemplateVariables method returns all variables from a DOCX. There's no way to kno if the placeholder is in a table, paragraph or list using this method (all these contents include a paragraph). Using getDocxPathQueryInfo you can query by many content types, such as list type, for example using the file TemplateList.docx included in the package:

$docx = new CreateDocxFromTemplate('examples/files/TemplateList.docx');

$referenceNode = array(
    'type' => 'list',

$queryInfo = $docx->getDocxPathQueryInfo($referenceNode);

foreach ($queryInfo['elements'] as $element) {

You can iterate the elements key and get each value using the textContent attribute, that removes the tags to get the value of each result and returns the value of each list paragraph (in a DOCX a list is a paragraph with some specific w:numPr and w:ilvl tags). Using this code you can iterate the elements to get only those strings that contain the symbols uses to wrap the placeholders ($ as default).