28 lines
840 B
PHP
28 lines
840 B
PHP
<?php
|
|
$file = file_get_contents('https://www.lubiebuty.pl/modules/x13googlemerchant/xml/gm_shop1_lang1_currency1.xml');
|
|
$xml = new SimpleXMLElement($file);
|
|
$xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
|
|
$xml->registerXPathNamespace('g', 'http://base.google.com/ns/1.0');
|
|
|
|
foreach ($xml->xpath('//atom:entry/*[
|
|
not(
|
|
name() = "g:id"
|
|
or name() = "g:title"
|
|
or name() = "g:link"
|
|
or name() = "g:image_link"
|
|
or name() = "g:brand"
|
|
)
|
|
]') as $child) unset($child[0]);
|
|
|
|
|
|
$label_name = 'g:mpn';
|
|
$g_id = 'g:id';
|
|
|
|
foreach ($xml->xpath('//atom:entry') as $entry) {
|
|
$id = $entry->children('g', true)->id;
|
|
$entry->$label_name = $id ? (string)$id : '';
|
|
}
|
|
|
|
$xml -> asXml( 'new-xml.xml' );
|
|
echo '<p>wygenerowano https://cdn.projectpro.pl/lubiebuty.pl/new-xml.xml</p>';
|
|
?>
|