0

I want to add, replace some tags, CDATAS etc.want to edit and save the file back replacing the previous one.same compression level and type (it's a gzip archive) used in the file, to be maintained. I know how to read complete xml file. Here is how much I know. need to write and compress it back. The original compressed file name is "mycompressedgzipfile.gzip".

<?php
$xml = simplexml_load_file("compress.zlib://mycompressedgzipfile.xml",'SimpleXMLElement',LIBXML_NOCDATA);
echo '<pre>';
print_r($xml);
echo '</pre>';
?>
aimme
  • 6,385
  • 7
  • 48
  • 65
  • 1
    same way you opened it. establish a stream with zlib settings, and write to it. – Marc B Oct 31 '13 at 19:22
  • can i use gzwrite() ? is that the one – aimme Oct 31 '13 at 19:38
  • 1
    You just save it as you opened it (sidenote: you can spare the two last parameters as you open it most probably). Just store the whole filename incl. the wrapper in front into a variable and use that variable. You can use that variable then with [`SimpleXMLElement::asXML()`](http://php.net/SimpleXMLElement.asXML) – hakre Nov 02 '13 at 05:48

0 Answers0