Forum


Replies: 4   Views: 2413
How to get elements of a specific table.
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  · 22-07-2019 - 09:02

Hello,

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.

Regards.