Thank you very much!
While testing we now found a problem when using a variable multiple times in a document. Because there can be multiple nodes with the same variable the inner foreach loop should not refresh the document. That's because the nodes that are being iterated and modified still belong to the original document. So the added lines should be inserted a few lines below at the end of the outer foreach loop.
foreach ($variables as $variable => $value) {
// ...
foreach ($foundNodes as $node) {
// ...
}
$dom = $this->generateDomDocument($dom->saveXML());
$xpath = new \DOMXPath($dom);
$xpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
}
Is this problem known? And is this a viable fix or is there a different solution to the underlying problem?
Regards.