Create new XML file and write data to it?

后端 未结 3 438
长情又很酷
长情又很酷 2020-11-30 00:22

I need to create a new XML file and write that to my server. So, I am looking for the best way to create a new XML file, write some base nodes to it, save it. Then open it a

3条回答
  •  爱一瞬间的悲伤
    2020-11-30 01:05

    With FluidXML you can generate and store an XML document very easily.

    $doc = fluidxml();
    
    $doc->add('Album', true)
            ->add('Track', 'Track Title');
    
    $doc->save('album.xml');
    

    Loading a document from a file is equally simple.

    $doc = fluidify('album.xml');
    
    $doc->query('//Track')
            ->attr('id', 123);
    

    https://github.com/servo-php/fluidxml

提交回复
热议问题