Forum


Replies: 1   Views: 3101
How to remove a section having some specified content/word/phrase?
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 vinaya180189  · 13-10-2016 - 06:46

I have a doc which contains sections( multiple ).

I wants to remove a particular section which contains some text. I am using xpath.

snippet :

$referenceNode= array(
'type' => 'section',
'contains' => 'Bali'
);
$queryInfo = $docx->getDocxPathQueryInfo($referenceNode);

But queryinfo gives me :

Array
(
    [length] => 0
    [query] => //w:body/w:p/w:pPr/w:sectPr[1=1 and  contains(., 'Mali')]/../..
)

  I tried to get a section by it occurrence and its working fine and I am able to remove that section also. But with 'contains' its not working.

I am using removeWordContent method to remove a section.

$docx->removeWordContent($referenceNode);

  Also If I am trying to remove a paragraph which contains some particular text it also gets removed successfully.

   Can you please assist How can we achieve it?