Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
Edit an XML within compressed tgz file without extracting it

I have been trying to modify an XML document within an archived .tgz file by using the PharData class using php. I have no problem modifying the XML through DomDocument class, but I am having a hard time saving the whole process: I end up saving 2 different .phar documents alltogether, w/o modifying anything in the .tgz archive :

folder example image

Here is the code I have been using :

            $phar = new PharData($path . '/' . $idClient . '/' . $tempDate->format('ym') . '/' . $file);

            echo $phar . "\n";

            $dom = new DOMDocument();
            $dom->load ('phar://' . $path . '/' . $idClient . '/' . $tempDate->format('ym') . '/' . $file . '/' . substr($file, 0, -4) . '.xml');

            if ($dom === null) continue;
            $ids = $dom->documentElement->getElementsByTagName('id');

            foreach ($ids as $i_id) {
                if ($i_id->nodeValue !== $id) continue;
                echo $i_id->nodeValue . "\n";
                echo $i_id->nodeName . "\n";
                $sensor = $i_id->parentNode;
                echo $sensor->nodeName . "\n";
                foreach ($sensor->childNodes as $object) {
                    if ($object->nodeName !== 'type') continue;
                    echo $object->nodeName . "\n";
                    echo $object->nodeValue . "\n";
                    $object->nodeValue = $type;
                    echo $object->nodeValue . "\n" . "\n";
                }       
            }
            $dom->save('phar://' . $path . '/' . $idClient . '/' . $tempDate->format('ym') . '/' . $file . '.phar' . '/' . substr($file, 0, -4) . '.xml');
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda