Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php DomeElement-在插入时运行方法?_Php_Domdocument - Fatal编程技术网

php DomeElement-在插入时运行方法?

php DomeElement-在插入时运行方法?,php,domdocument,Php,Domdocument,嗯,我或多或少想要的是php中的eventhandler…-我想 我正在编写一个php脚本来生成一个xml文件(确切地说是ansi n42.42文件),我想做的是能够定义各种“子树”,并将它们合并到最终的文档中。我使用构建子树所需的属性将这些子树定义为扩展DOMNode。由于domnode在插入到DOMDocument之前是不可变的,因此我定义了一个构建方法,在我将其关联起来进行设置之后运行该方法: 在我的课堂上:(为了简洁起见去掉了一些部分) 然后使用它: $cal = new calibra

嗯,我或多或少想要的是php中的eventhandler…-我想

我正在编写一个php脚本来生成一个xml文件(确切地说是ansi n42.42文件),我想做的是能够定义各种“子树”,并将它们合并到最终的文档中。我使用构建子树所需的属性将这些子树定义为扩展DOMNode。由于domnode在插入到DOMDocument之前是不可变的,因此我定义了一个构建方法,在我将其关联起来进行设置之后运行该方法:

在我的课堂上:(为了简洁起见去掉了一些部分)

然后使用它:

$cal = new calibration("-4, 3.12","cal_id");
$n42->firstChild->appendChild($cal);  // n42 is the object extending DOMDocument
$cal->build();
将$cal追加到树中时,是否有可能使$cal->build()自动运行


(或者我是不是找错了方向,从一开始就使用DOMFragment会更好?

如果我理解正确,那么您可以向脚本中添加观察者,他们将负责更改DOMDocument。如果我理解正确的话。

观察-听起来像是我需要的!坦斯克@尤金!
$cal = new calibration("-4, 3.12","cal_id");
$n42->firstChild->appendChild($cal);  // n42 is the object extending DOMDocument
$cal->build();