用DOM组件创建xml文档

xml.php:

<?php
	$doc=new DOMDocument('1.0','utf-8');
	$doc->formatOutput=true;
	
	$title=$doc->createElement('title');
	$body=$doc->createElement('body');
	
	$topAll=$doc->createTextNode('good day');
	$bodyAll=$doc->createTextNode('good Today');
	
	$title->appendChild($body);
	$doc->appendChild($title);
	
	$title->appendChild($topAll);
	$body->appendChild($bodyAll);
	
	$doc->save("php.xml");
?>
生成的文件 php.xml :




你可能感兴趣的:(用DOM组件创建xml文档)