{"id":95,"date":"2013-12-13T08:11:30","date_gmt":"2013-12-13T08:11:30","guid":{"rendered":"http:\/\/tastaturkind.ch\/?p=95"},"modified":"2013-12-13T08:11:30","modified_gmt":"2013-12-13T08:11:30","slug":"php-simple-dom-example","status":"publish","type":"post","link":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/2013\/12\/13\/php-simple-dom-example\/","title":{"rendered":"PHP Simple DOM Example"},"content":{"rendered":"<p><code><?php\n\n    $dom = new DOMDocument('1.0', 'iso-8859-1');\n\n    $root = $dom->createElement('cds');<br \/>\n    $dom->appendChild($root);<\/p>\n<p>    mysql_connect(\"localhost\",\"root\",\"\");<br \/>\n    mysql_select_db(\"cdcol\");<\/p>\n<p>    $result=mysql_query(\"SELECT id,titel,interpret,jahr FROM cds ORDER BY interpret;\");<\/p>\n<p>    while( $row=mysql_fetch_array($result) )<br \/>\n    {<br \/>\n\t    $cd = $dom->createElement('cd');<br \/>\n\t    $cd->setAttribute('id', $row['id']);<\/p>\n<p>\t    $titel = $dom->createElement('titel');<br \/>\n\t    $titel->appendChild($dom->createTextNode($row['titel']));<br \/>\n\t    $cd->appendChild($titel);<\/p>\n<p>\t    $interpret = $dom->createElement('interpret');<br \/>\n\t    $interpret->appendChild($dom->createTextNode($row['interpret']));<br \/>\n\t    $cd->appendChild($interpret);<\/p>\n<p>\t    $jahr = $dom->createElement('jahr');<br \/>\n\t    $jahr->appendChild($dom->createTextNode($row['jahr']));<br \/>\n\t    $cd->appendChild($jahr);<\/p>\n<p>\t    $root->appendChild($cd);<br \/>\n    }<\/p>\n<p>    header(\"Content-Type: text\/xml;\");<br \/>\n\t$xml=\"<?xml version=\\\"1.0\\\" encoding=\\\"ISO-8859-1\\\" ?><br \/>\n<rss version=\\\"2.0\\\" xmlns:rdf=\\\"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#\\\" xmlns:admin=\\\"http:\/\/webns.net\/mvcb\/\\\" xmlns:dc=\\\"http:\/\/purl.org\/dc\/elements\/1.1\/\\\" xmlns:slash=\\\"http:\/\/purl.org\/rss\/1.0\/modules\/slash\/\\\" xmlns:wfw=\\\"http:\/\/wellformedweb.org\/CommentAPI\/\\\" xmlns:content=\\\"http:\/\/purl.org\/rss\/1.0\/modules\/content\/\\\"><br \/>\n<channel><br \/>\n\";<br \/>\necho $xml;<br \/>\nprint $dom->saveXML();<br \/>\necho \"<\/channel><\/rss>\";<br \/>\n?><br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":0,"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oliver-frick.ch\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}