Last active
August 29, 2015 14:10
-
-
Save blar/c351ef96a09b8f20797f to your computer and use it in GitHub Desktop.
Entwurf zu DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$document = new DomDocument(); | |
$atom = $document->getNamespace('http://www.w3.org/2005/Atom'); | |
$xhtml = $document->getNamespace('http://www.w3.org/1999/xhtml', 'xhtml'); | |
$feed = $atom->createElement('feed'); | |
$document->appendChild($feed); | |
$entry = $atom->createElement('entry'); | |
$title = $atom->createElement('title')->appendChild('Hello World'); | |
$entry->appendChild($title); | |
$content = $atom->createElement('content')->setAttribute('type', 'xhtml'); | |
$content->appendChild($xhtml->createElement('p')->appendChild('Hello World')); | |
$entry->appendChild($content); | |
$feed->appendChild($entry); | |
$document->normalizeNamespaces([$atom, $xhtml]); | |
echo $document; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"> | |
<entry> | |
<title>Hello World</title> | |
<content type="xhtml"> | |
<xhtml:p>Hello World</xhtml:p> | |
</content> | |
</entry> | |
</feed> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment