6 paź 2008

Utworzenie najprostszego dokumentu XML

$docs = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$pages = $docs->appendChild(new DOMElement('pages'));
$element_page = $pages->appendChild(new DOMElement('page'));
$element_page->setAttribute("id", "123456");
$element_name = $docs->createElement('link', 'link numer 123456');
$element_page->appendChild($element_name);
$element_CDATA = $docs->createCDATASection('http://kody.wig.pl/');
$element_url = $element_page->appendChild(new DOMElement('url'));
$element_url->appendChild($element_CDATA);
$xmldata = $docs->saveXML();
echo $xmldata;