Replies: 4   Views: 155
How to get elements of a specific table.

Posted by admin  · 22-07-2019 - 09:02


The code you are using to get a reference node by an attribute isn't correct. This sample is included in the package:

$referenceNode = array(
        'type' => 'paragraph',
    'occurrence' => 1,
    'attributes' => array('w:outlineLvl' => array('w:val' => 2)),

This reference node returns the first paragraph with a tag w:outlineLvl that include the attribute w:val=2. But it returns the whole paragraph, so if you use a similar code to get a table you get the whole table contents, not only the first cell.

If you get the whole table you can analyze its contents (using PHP DOM methods) using getDocxPathQuery. Using getWordContents you'd need to use a custom query, please check the included samples and the documentation about how to use custom queries. If you open a support ticket ( and attach a DOCX sample the dev team we'll generate a custom script with a custom Xpath query.