Watch 1 Star 0 Fork 2

sandy / mimvp-sitemap-phpPHPMIT

forked from mimvp / mimvp-sitemap-php 
Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
Clone or download
test_xml_write.php 1.13 KB
Copy Edit Web IDE Raw Blame History
homer authored 2017-08-08 22:12 . commit mimvp-sitemap-php
<?php
/**
* mimvp.com
* 2017.06.22
*/
header("Content-type: text/html; charset=utf-8");
$xml = new XMLWriter();
$xml->openUri("php://output"); // 输出到网页控制台
$xml->openUri("mimvp.xml"); // 输出到文件,需要读写权限,推荐 chmod 766 mimvp.xml
// 设置缩进字符串
$xml->setIndentString("\t");
$xml->setIndent(true);
// xml文档开始
$xml->startDocument('1.0', 'utf-8');
// 创建根节点
$xml->startElement("MimvpInfo");
// 节点1
$xml->startElement("Item");
$xml->writeAttribute("info","1"); // 属性
$xml->startElement("id");
$xml->text("01");
$xml->endElement();
$xml->startElement("name");
$xml->text("米扑代理");
$xml->endElement();
$xml->endElement();
// 节点2
$xml->startElement("Item");
$xml->writeAttribute("info","1"); // 属性
$xml->startElement("id");
$xml->text("02");
$xml->endElement();
$xml->startElement("name");
$xml->text("米扑财富");
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->endDocument();
//header("Content-type: text/xml");
//取得缓冲区里的xml字符串
//echo $xml->outputMemory();
?>

Comment ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/sandyme/sitemap-php.git
git@gitee.com:sandyme/sitemap-php.git
sandyme
sitemap-php
mimvp-sitemap-php
master

Help Search