Mercurial > hg > extraction-interface
diff _xampp/contrib/dom.php @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_xampp/contrib/dom.php Mon Jan 19 17:13:49 2015 +0100 @@ -0,0 +1,35 @@ +<?php + + $dom = new DOMDocument('1.0', 'iso-8859-1'); + + $root = $dom->createElement('cds'); + $dom->appendChild($root); + + mysql_connect("localhost","root",""); + mysql_select_db("cdcol"); + + $result=mysql_query("SELECT id,titel,interpret,jahr FROM cds ORDER BY interpret;"); + + while( $row=mysql_fetch_array($result) ) + { + $cd = $dom->createElement('cd'); + $cd->setAttribute('id', $row['id']); + + $titel = $dom->createElement('titel'); + $titel->appendChild($dom->createTextNode($row['titel'])); + $cd->appendChild($titel); + + $interpret = $dom->createElement('interpret'); + $interpret->appendChild($dom->createTextNode($row['interpret'])); + $cd->appendChild($interpret); + + $jahr = $dom->createElement('jahr'); + $jahr->appendChild($dom->createTextNode($row['jahr'])); + $cd->appendChild($jahr); + + $root->appendChild($cd); + } + + header("Content-Type: text/xml;"); + print $dom->saveXML(); +?>