<?php
/*
* This is a simple example to show the creation process of a xml document.
* This example works with PHP4 and PHP5.
*
* This model was extracted from the PHP Manual at 'DOM Functions'
* chapter
*/
require_once("DOMAdapter.inc");
header("Content-Type: text/xml");
//header("Content-Type: text/plain");
$xml = new DOMAdapter();
$doc = $xml->createDocument("book");
$doc->documentElement->setAttribute("id", "listing");
$title = $doc->createElement("title");
$title->appendChild($doc->createTextNode("My lists"));
$doc->documentElement->appendChild($title);
$chapter = $doc->createElement("chapter");
$chapter->setAttribute("id", "books");
$doc->documentElement->appendChild($chapter);
$title = $doc->createElement("title");
$title->appendChild($doc->createTextNode("My books"));
$chapter->appendChild($title);
$para = $doc->createElement("para");
$chapter->appendChild($para);
$informaltable = $doc->createElement("informaltable");
$para->appendChild($informaltable);
$tgroup = $doc->createElement("tgroup");
$tgroup->setAttribute("cols", 4);
$informaltable->appendChild($tgroup);
$thead = $doc->createElement("thead");
$tgroup->appendChild($thead);
$row = $doc->createElement("row");
$thead->appendChild($row);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("Title"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("Author"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("Language"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("ISBN"));
$row->appendChild($entry);
$tbody = $doc->createElement("tbody");
$tgroup->appendChild($tbody);
$row = $doc->createElement("row");
$tbody->appendChild($row);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("The Grapes of Wrath"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("John Steinbeck"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("en"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("0140186409"));
$row->appendChild($entry);
$row = $doc->createElement("row");
$tbody->appendChild($row);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("The Pearl"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("John Steinbeck"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("en"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("014017737X"));
$row->appendChild($entry);
$row = $doc->createElement("row");
$tbody->appendChild($row);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("Samarcande"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("Amine Maalouf"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("fr"));
$row->appendChild($entry);
$entry = $doc->createElement("entry");
$entry->appendChild($doc->createTextNode("2253051209"));
$row->appendChild($entry);
echo $doc->saveXML();
?>
|