Hello,
You need to use getWordContents. As you can read on the API page (https://www.phpdocx.com/api-documentation/docx-path/get-text-word-contents-in-docx), you can query by its position, content, attributes or even a custom XPath query. Please check the included samples in the package.
Regards.