$file = file_get_contents('https://drmaterac.pl/modules/xmlfeeds/xml_files/feed_17.xml'); $doc = new DOMDocument(); $doc->loadXML($file); $xpath = new DOMXPath($doc); $xpath->registerNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xpath->query('//channel/item'); $channel = $xpath->query('//channel')->item(0); // Znajdź element channel, aby usunąć elementy item $itemCount = 0; // Inicjalizuj licznik elementów item foreach ($items as $item) { $itemCount++; // Zwiększ licznik elementów item if ( $itemCount > 9999 ) { $channel -> removeChild( $item ); continue; } // $google_category = $xpath->evaluate('string(g:google_product_category)', $item); $brand = $xpath->evaluate('string(g:brand)', $item); $custom_label_0 = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:custom_label_0', 'Materace ' . $brand ); $item -> appendChild( $custom_label_0 ); $nodesToRemove = array(); foreach ( $item -> childNodes as $child ) { $nodeName = $child->nodeName; if ( $nodeName !== 'g:id' && $nodeName !== 'g:title' && $nodeName !== 'g:custom_label_0' and $nodeName !== 'product_category_tree' ) { $nodesToRemove[] = $child; } } foreach ($nodesToRemove as $node) { $item->removeChild($node); } } $doc -> save( 'materace-marki.xml' ); echo '
wygenerowano https://cdn.projectpro.pl/lulandia.pl/materace-marki.xml
'; $file = file_get_contents('https://drmaterac.pl/modules/xmlfeeds/xml_files/feed_18.xml'); $doc = new DOMDocument(); $doc->loadXML($file); $xpath = new DOMXPath($doc); $xpath->registerNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xpath->query('//channel/item'); $channel = $xpath->query('//channel')->item(0); // Znajdź element channel, aby usunąć elementy item $itemCount = 0; // Inicjalizuj licznik elementów item foreach ($items as $item) { $itemCount++; // Zwiększ licznik elementów item if ( $itemCount > 9999 ) { $channel -> removeChild( $item ); continue; } $brand = $xpath->evaluate('string(g:brand)', $item); $custom_label_0 = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:custom_label_0', 'Łóżka ' . $brand ); $item -> appendChild( $custom_label_0 ); $nodesToRemove = array(); foreach ( $item -> childNodes as $child ) { $nodeName = $child->nodeName; if ( $nodeName !== 'g:id' && $nodeName !== 'g:title' && $nodeName !== 'g:custom_label_0' and $nodeName !== 'product_category_tree' ) { $nodesToRemove[] = $child; } } foreach ($nodesToRemove as $node) { $item->removeChild($node); } } $doc -> save( 'lozka-marki.xml' ); echo 'wygenerowano https://cdn.projectpro.pl/lulandia.pl/lozka-marki.xml
'; $file = file_get_contents('https://drmaterac.pl/modules/xmlfeeds/xml_files/feed_19.xml'); $doc = new DOMDocument(); $doc->loadXML($file); $xpath = new DOMXPath($doc); $xpath->registerNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xpath->query('//channel/item'); $channel = $xpath->query('//channel')->item(0); // Znajdź element channel, aby usunąć elementy item $itemCount = 0; // Inicjalizuj licznik elementów item foreach ($items as $item) { $itemCount++; // Zwiększ licznik elementów item if ( $itemCount > 9999 ) { $channel -> removeChild( $item ); continue; } $brand = $xpath->evaluate('string(g:brand)', $item); $custom_label_0 = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:custom_label_0', 'Stelaże ' . $brand ); $item -> appendChild( $custom_label_0 ); $nodesToRemove = array(); foreach ( $item -> childNodes as $child ) { $nodeName = $child->nodeName; if ( $nodeName !== 'g:id' && $nodeName !== 'g:title' && $nodeName !== 'g:custom_label_0' and $nodeName !== 'product_category_tree' ) { $nodesToRemove[] = $child; } } foreach ($nodesToRemove as $node) { $item->removeChild($node); } } $doc -> save( 'stelaze-marki.xml' ); echo 'wygenerowano https://cdn.projectpro.pl/lulandia.pl/stelaze-marki.xml
'; $file = file_get_contents('https://drmaterac.pl/modules/xmlfeeds/xml_files/feed_20.xml'); $doc = new DOMDocument(); $doc->loadXML($file); $xpath = new DOMXPath($doc); $xpath->registerNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xpath->query('//channel/item'); $channel = $xpath->query('//channel')->item(0); // Znajdź element channel, aby usunąć elementy item $itemCount = 0; // Inicjalizuj licznik elementów item foreach ($items as $item) { $itemCount++; // Zwiększ licznik elementów item if ( $itemCount > 9999 ) { $channel -> removeChild( $item ); continue; } $brand = $xpath->evaluate('string(g:brand)', $item); $custom_label_0 = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:custom_label_0', 'Akcesoria ' . $brand ); $item -> appendChild( $custom_label_0 ); $nodesToRemove = array(); foreach ( $item -> childNodes as $child ) { $nodeName = $child->nodeName; if ( $nodeName !== 'g:id' && $nodeName !== 'g:title' && $nodeName !== 'g:custom_label_0' and $nodeName !== 'product_category_tree' ) { $nodesToRemove[] = $child; } } foreach ($nodesToRemove as $node) { $item->removeChild($node); } } $doc -> save( 'akcesoria-marki.xml' ); echo 'wygenerowano https://cdn.projectpro.pl/lulandia.pl/akcesoria-marki.xml
'; $file = file_get_contents('https://drmaterac.pl/modules/xmlfeeds/xml_files/feed_21.xml'); $doc = new DOMDocument(); $doc->loadXML($file); $xpath = new DOMXPath($doc); $xpath->registerNamespace('g', 'http://base.google.com/ns/1.0'); $items = $xpath->query('//channel/item'); $channel = $xpath->query('//channel')->item(0); // Znajdź element channel, aby usunąć elementy item $itemCount = 0; // Inicjalizuj licznik elementów item foreach ($items as $item) { $itemCount++; // Zwiększ licznik elementów item if ( $itemCount > 9999 ) { $channel -> removeChild( $item ); continue; } $brand = $xpath->evaluate('string(g:brand)', $item); $custom_label_0 = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:custom_label_0', 'Meble ' . $brand ); $item -> appendChild( $custom_label_0 ); $nodesToRemove = array(); foreach ( $item -> childNodes as $child ) { $nodeName = $child->nodeName; if ( $nodeName !== 'g:id' && $nodeName !== 'g:title' && $nodeName !== 'g:custom_label_0' and $nodeName !== 'product_category_tree' ) { $nodesToRemove[] = $child; } } foreach ($nodesToRemove as $node) { $item->removeChild($node); } } $doc -> save( 'meble-marki.xml' ); echo 'wygenerowano https://cdn.projectpro.pl/lulandia.pl/meble-marki.xml
';