XML::LibXML replace element value

前端 未结 2 1725
眼角桃花
眼角桃花 2020-12-06 12:57

I want to replace a \"VAL1\" value of an element in xml file

For some reason it does not work for me:

   
TEST         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 13:17

    There is no setValue method in Node or Element classes, see the docs for list of available methods. You can remove children of the element and append new text node like this:

    $elem->removeChildNodes();
    $elem->appendText('VAL2');
    

提交回复
热议问题