edit XML with simpleXML

前端 未结 4 418
醉酒成梦
醉酒成梦 2020-11-30 14:56

How can I edit the value\'s in a xml file using simpleXML ?

I know how to create the file, but not how to edit the value in an existing file ?

4条回答
  •  囚心锁ツ
    2020-11-30 15:47

    Sure you can edit with SimpleXML:

    $input = <<
    
      
        spec.doc
      
    
    END;
    
    $xml = new SimpleXMLElement($input);
    $xml->document[0]->name = 'spec.pdf';
    $output = $xml->asXML();
    

    Take a look at the examples.

提交回复
热议问题