Hello I am having this codes:
<?php
// Add new book using DOM
$dom = new DomDocument();
$dom->load("books.xml");
$book = $dom->createElement("book");
$book->setAttribute("isbn", "0973589825");
$title = $dom->createElement("title");
$text = $dom->createTextNode("php|architect’s Guide to PHP Design
Patterns");
$title->appendChild($text);
$book->appendChild($title);
$author = $dom->createElement("author", "Jason E. Sweat");
$book->appendChild($author);
$publisher = $dom->createElement("publisher", "Marco Tabini &
Associates, Inc.");
$book->appendChild($publisher);
$dom->documentElement->appendChild($book);
// show them on the screen
$file = file_get_contents('books.xml');
$buku = new SimpleXMLElement($file);
foreach ($buku as $buku){
# echo buku attribute
//echo $buku['isbn']."<br>";
# echo childs
echo $buku->judul."<br>";
?>
I wonder why the new title hasn't been added. What did I did wrong in adding the new title ?