createElement('Ads'); $root->setAttribute('formatVersion', '3'); $root->setAttribute('target', 'Avito.ru'); $doc->appendChild($root); foreach($marks['items'] as $k => $v) { $q = $v['quality']; if($q == 'НеГоден') continue; $name = htmlspecialchars($v['name']); $desc = htmlspecialchars($v['desc']); $price = (int)$v['price']; if(!$price || preg_match('%(б/у|б\.у)%isu', $name)) continue; $it = $doc->createElement('Ad'); $root->appendChild($it); $it2 = $doc->createElement('Id', $k); $it->appendChild($it2); $it2 = $doc->createElement('ListingFee', $sets['AVITO_ListingFee']); $it->appendChild($it2); $it2 = $doc->createElement('AdStatus', $sets['AVITO_AdStatus']); $it->appendChild($it2); $it2 = $doc->createElement('AllowEmail', $sets['AVITO_AllowEmail']); $it->appendChild($it2); $it2 = $doc->createElement('ManagerName', $sets['AVITO_ManagerName']); $it->appendChild($it2); $it2 = $doc->createElement('ContactPhone', $sets['AVITO_ContactPhone']); $it->appendChild($it2); $it2 = $doc->createElement('Region', $sets['AVITO_Region']); $it->appendChild($it2); $it2 = $doc->createElement('City', $sets['AVITO_City']); $it->appendChild($it2); $it2 = $doc->createElement('District', $sets['AVITO_District']); $it->appendChild($it2); $it2 = $doc->createElement('Category', $sets['AVITO_Category']); $it->appendChild($it2); $it2 = $doc->createElement('GoodsType', $sets['AVITO_GoodsType']); $it->appendChild($it2); $it2 = $doc->createElement('AdType', $sets['AVITO_AdType']); $it->appendChild($it2); $it2 = $doc->createElement('Title', $name); $it->appendChild($it2); $it2 = $doc->createElement('Description', $desc); $it->appendChild($it2); $it2 = $doc->createElement('Price', $price); $it->appendChild($it2); if($v['image']) { $imgs = $doc->createElement('Images'); $it2 = $doc->createElement('Image'); $it2->setAttribute('url', 'https://ttepla.com' . $v['image']); $imgs->appendChild($it2); $it->appendChild($imgs); } $root->appendChild($it); } $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $xml_string = $doc->saveXML(); Header('Content-type: text/xml'); echo $xml_string;