ute("language", "ge");
domxml_node_set_content($head,"ppp"); // 设置节点的内容,多次执行是叠加的
domxml_node_set_content($head,"ttt");
// 是乎函数名中只有1-2个"_"的函数,可作为对象的方法使用
$myxml = $doc->dumpmem();
echo "自定义xml<br>";
echo "<textarea cols=60 rows=5>$myxml</textarea><br>";
// 节点的遍历
/**
节点结构
domelement object
type = 1
tagname = 节点名
domtext object
type = 3
content = 节内容点
domcdata object
type = 4
content = 节内容点
domprocessinginstruction object
type 无
target = 处理指令
data = 参数
*/
$ar[] = $doc->root(); // 取得根节点
$ar[] = $ar[count($ar)-1]->children();
$ar[] = $ar[count($ar)-1][0]->children();
// 函数domxml_children() 不能返回节点参数
// 返回节点参数需要使用domxml_attributes()
//var_dump(domxml_attributes($head));
//print_r($ar[1][0]->attributes());
//print_r($ar);
function xml_dumpmem($xmldoc) {
static $mode = 0;
$xmlstr = "";
// 获取节点,保存在数组中
if(get_class($xmldoc) == "domdocument") {
$xmlstr = '<?xml version="1.0" encoding="gb2312"?>'."\n";
if(count($xmldoc->children) == 1) // 根节点,没有其他成员
$docs[] = $xmldoc->root();
else
$docs = $xmldoc->children(); // 根节点,有其他成员
}else {
$docs = $xmldoc->chi
domxml_node_set_content($head,"ppp"); // 设置节点的内容,多次执行是叠加的
domxml_node_set_content($head,"ttt");
// 是乎函数名中只有1-2个"_"的函数,可作为对象的方法使用
$myxml = $doc->dumpmem();
echo "自定义xml<br>";
echo "<textarea cols=60 rows=5>$myxml</textarea><br>";
// 节点的遍历
/**
节点结构
domelement object
type = 1
tagname = 节点名
domtext object
type = 3
content = 节内容点
domcdata object
type = 4
content = 节内容点
domprocessinginstruction object
type 无
target = 处理指令
data = 参数
*/
$ar[] = $doc->root(); // 取得根节点
$ar[] = $ar[count($ar)-1]->children();
$ar[] = $ar[count($ar)-1][0]->children();
// 函数domxml_children() 不能返回节点参数
// 返回节点参数需要使用domxml_attributes()
//var_dump(domxml_attributes($head));
//print_r($ar[1][0]->attributes());
//print_r($ar);
function xml_dumpmem($xmldoc) {
static $mode = 0;
$xmlstr = "";
// 获取节点,保存在数组中
if(get_class($xmldoc) == "domdocument") {
$xmlstr = '<?xml version="1.0" encoding="gb2312"?>'."\n";
if(count($xmldoc->children) == 1) // 根节点,没有其他成员
$docs[] = $xmldoc->root();
else
$docs = $xmldoc->children(); // 根节点,有其他成员
}else {
$docs = $xmldoc->chi
| 对此文章发表了评论 |
