php生成XML文档源代码_PHP教程
时间:2021-07-01 10:21:17
帮助过:20人阅读
生成XML源代码:
$dom = new DOMDocument();
if(!$dom)
{
printf("构造XML失败!
");
return -3999;
}
if(FALSE == ($dom->load($filename)))
{
add_root();
if(FALSE
== ($dom->load($filename)))
{
return -3999;
}
}
//引用root根节点
$f_node =
$dom->getElementsByTagName($parent_node)->item(0);
if(!$f_node)
{
$root =
$dom->getElementsByTagName(root)->item(0);
//创建父节点
$f_node =
$dom->createElement($parent_node);
$f_node =
$root->appendChild($f_node);
}
//创建节点
$item_node =
$dom->createElement($node);
$item_node =
$f_node->appendChild($item_node);
$item_value =
$dom->createTextNode($value);
$item_node->appendChild($item_value);
http://www.bkjia.com/PHPjc/486219.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486219.htmlTechArticle生成XML源代码: $dom = new DOMDocument ( ) ; if ( ! $ dom ) { printf ( "构造XML失败!" ) ; return - 3999 ; } if ( FALSE = = ( $ dom - load ( $ filename ) ) ) { add_root (...
人气教程排行
|