36 lines
799 B
PHP
36 lines
799 B
PHP
<?php
|
|
error_reporting(E_ALL);
|
|
ini_set("display_errors", 1);
|
|
|
|
echo "<h1>XML Ausgabe</h1>";
|
|
|
|
// load xml file
|
|
$xmlDoc = new DOMDocument();
|
|
$xmlDoc->load("personen.xml");
|
|
|
|
echo "<h2>Einfach</h1>";
|
|
|
|
// simple output
|
|
echo $xmlDoc->saveXML();
|
|
|
|
echo "<hr>";
|
|
|
|
echo "<h2>Gesamte Knoten</h1>";
|
|
|
|
// output of individual nodes
|
|
$benutzer=$xmlDoc->getElementsByTagName("benutzer");
|
|
|
|
foreach($benutzer as $benutzerDaten){
|
|
echo "<strong>Person: </strong>".$benutzerDaten->textContent."<br>";
|
|
}
|
|
|
|
echo "<hr>";
|
|
echo "<h2>Element eines Knotens</h1>";
|
|
// output of an node's element
|
|
foreach($benutzer as $benutzerDaten){
|
|
foreach($benutzerDaten->childNodes as $element){
|
|
if($element->nodeName == "benutzername"){
|
|
echo "<strong>Person: </strong>".$element->textContent."<br>";
|
|
}
|
|
}
|
|
} |