How can I set text value of SimpleXmlElement without using its parent?

前端 未结 2 1149
轻奢々
轻奢々 2020-11-27 23:35

I want to set text of some node found by xpath()


  
    text
          


        
2条回答
  •  猫巷女王i
    2020-11-28 00:10

    The real answer is: you kind of can't.

    On the other hand you can use DOM for it, e.g.

    dom_import_simplexml($node)->nodeValue = 'foo';
    

提交回复
热议问题