我有两个 xml 数组,我想将这些数组合并到第三个数组中……第一个 xml 结构是
$current = '<forms id="frm16648">
<group ref="" id="tarascioheader" mode="block">
<label>
<![CDATA[Group (tarascioheader)]]>
</label> structure u
<select ref="" id="petorresp">
<label>
<![CDATA[Select (petorresp)]]>
</label>
</select>
第二个数组是
$old = '<forms id="frm16648">
<group ref="" id="tarascioheader" mode="block">
<label>
<![CDATA[abc]]>
</label>
</group>
</forms>':
</group>
</forms>';
从这些 xmls 中,我想复制新数组中的所有匹配标签......我试图通过一个递归函数来做到这一点......
function merge_xmls($current, $old)
{
$cxml = str_get_html($current);
$oxml = str_get_html($old);
do
{
$tt = $cxml->first_child();
if(!empty($tt) && !is_null($cxml->first_child()))
{
$x = $cxml->first_child();
$this->merge_xmls($x, $cxml, $oxml);
}
if(empty($tt))
{
$cid = $cxml->id;
$oid = $oxml -> find('#'.$cid);
if(!is_null($oid))
{
$cxml -> innerHTML = $oxml -> innerHTML;
}
}
$cxml = $cxml->next_sibling();
}
while(!empty($cxml) && !is_null($cxml));
}