<?
$file = file_get_contents('https://sklep.elitex.pl/wp-content/uploads/woo-product-feed-pro/xml/bl5bsl12t85oQOpuLr4OvdgYGB8cIjNe.xml');
$xml = new SimpleXMLElement($file);

foreach ($xml->xpath('//item/*[
    not(
           name() = "g:id"
        or name() = "g:title"
        or name() = "g:product_type"
    )
]') as $child) unset($child[0]);

$label_name = 'g:custom_label_0';
$label_name_1 = 'g:custom_label_0';
$product_type = 'g:product_type';

for ( $i = 0; $i < count( $xml -> channel -> item ); $i++ )
{
  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Komplety pościeli' ) !== false )
    $xml -> channel -> item[$i] -> $label_name = 'komplety-poscieli';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Poszewki pościelowe' ) !== false )
    $xml -> channel -> item[$i] -> $label_name = 'poszewki-poscielowe';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Prześcieradła' ) !== false )
    $xml -> channel -> item[$i] -> $label_name = 'przescieradla';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Podkłady ochronne' ) !== false )
    $xml -> channel -> item[$i] -> $label_name = 'podklady-ochronne';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Kołdry' ) !== false )
    $xml -> channel -> item[$i] -> $label_name = 'koldry';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Satyna bawełniana' ) !== false )
    $xml -> channel -> item[$i] -> $label_name_1 = 'satyna-bawelniana';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Dekoracje okna > Firany' ) !== false )
    $xml -> channel -> item[$i] -> $label_name_1 = 'dekoracje-okienne-firany';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Dekoracje okna > Dodatki' ) !== false )
    $xml -> channel -> item[$i] -> $label_name_1 = 'dekoracje-okienne-dodatki';

  if ( mb_strpos( $xml -> channel -> item[$i] -> children('g', true ) -> product_type, 'Dekoracje okna > Zasłony' ) !== false )
    $xml -> channel -> item[$i] -> $label_name_1 = 'dekoracje-okienne-zaslony';
}
$xml -> asXml( 'custom_label_0.xml' );
echo '<p>wygenerowano https://cdn.projectpro.pl/elitex.pl/custom_label_0.xml</p>';
