function getXmlNapojak() { $d = new DomDocument('1.0', 'utf-8'); $root_e = $d->createElement('napojak'); foreach (MyDB::getInstance()->getResults(MyDB::getQuery(SELECT_NAPOJAK_KAT)) as $kat) { $kat_e = $d->createElement('kategorie'); $kat_e->setAttribute('id', $kat['id']); $kat_e->setAttribute('nazev', $kat['nazev']); $kat_e->setAttribute('popis', $kat['popis']); $param = array(':kat_id' => $kat['id']); foreach (MyDB::getInstance()->getParamResults(MyDB::getQuery(SELECT_NAPOJAK), $param) as $row) { $item_e = $d->createElement('item'); $item_e->setAttribute('id', $row['id']); $item_e->setAttribute('nazev', $row['nazev']); $item_e->setAttribute('popis', $row['popis']); $item_e->setAttribute('cena', $row['cena']); $en = (bool) $row['en'] ? "true" : "false"; $item_e->setAttribute('en', $en); $kat_e->appendChild($item_e); } $root_e->appendChild($kat_e); } $d->appendChild($root_e); return $d->saveXML(); }
function getXmlNews() { $d = new DomDocument('1.0', 'utf-8'); $root_e = $d->createElement('news'); foreach (MyDB::getInstance()->getResults(MyDB::getQuery(SELECT_NEWS)) as $row) { $item_e = $d->createElement('item', $row['obsah']); $item_e->setAttribute('date', $row['datum']); $root_e->appendChild($item_e); } $d->appendChild($root_e); return $d->saveXML(); }