loadXML($xml); $importedFragment = $document->importNode($fragment->documentElement, true); $document->documentElement->appendChild($importedFragment); } $db=openDb(); $query = queryOneWatch($db); $watchRow = $query->fetch(SQLITE_ASSOC); $document = new DOMDocument(); $root = $document->createElement("root"); $document->appendChild($root); appendDocument( $document, getAllWatches($db) ); if ($watchRow) { appendDocument( $document, getAWatch($db, $_GET['name']) ); appendDocument( $document, get_cached_data( getUrlQuotes($watchRow['symbol']), get_quotes_as_xml, YAHOOFINANCE_QUOTES_LIFETIME ) ); appendDocument( $document, get_cached_data( getUrlFinancialNews($watchRow['symbol']), defaultCacheGet, YAHOOFINANCE_NEWS_LIFETIME ) ); appendDocument( $document, get_cached_data( getUrlDelicious($watchRow['tag']), defaultCacheGet, DELICIOUS_LIFETIME ) ); } if ($_GET['format'] == 'xml') { header("Cache-Control: max-age=60"); header("Content-type: application/xml"); print $document->saveXML(); exit; } $xsltSource = new DOMDocument(); $xsltProc = new XSLTProcessor(); $xsltSource->load('format.xsl'); $xsltProc->importStyleSheet($xsltSource); header("Cache-Control: max-age=60"); header("Content-type: text/html"); print $xsltProc->transformToXML($document); ?>