How can I wrap two chosen elements with a div using PHP's DOMDocument?

后端 未结 1 1987
闹比i
闹比i 2021-01-27 22:46

I have selected 2 elements (siblings) using PHP\'s DOMDocument (with a little help of DOMXPath).

$dom = new DOMDocument(\'1.0\', \'UTF-8\');

$dom->preserveWh         


        
相关标签:
1条回答
  • 2021-01-27 23:20

    You can use the appendChild() method to move an existing node. So:

    • Create a new div
    • Use appendChild on the new div to make your chosen elements a child of this div
    0 讨论(0)
提交回复
热议问题