时间:2021-07-01 10:21:17 帮助过:23人阅读
//建立
$response = $dom->createElement('response');
$dom->appendChild($response);
//建立
$books = $dom->createElement('books');
$response->appendChild($books);
//为book创建标题
$title = $dom->createElement('title');
$titleText = $dom->createTextNode('PHP与AJAX');
$title->appendChild($titleText);
//为book创建isbn元素
$isbn = $dom->createElement('isbn');
$isbnText = $dom->createTextNode('1-21258986');
$isbn->appendChild($isbnText);
//创建book元素
$book = $dom->createElement('book');
$book->appendChild($title);
$book->appendChild($isbn);
//将
$books->appendChild($book);
//在一字符串变量中建立XML结构
$xmlString = $dom->saveXML();
//输出XML字符串
echo $xmlString;
?>
http://www.bkjia.com/PHPjc/327454.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327454.htmlTechArticle第一种方法: 代码如下:?php header("Content-type: text/xml"); echo "?xml version=/"1.0/" encoding=/"UTF-8/"?"; echo "users"; echo "user"; echo "name"; echo "小...