0
我有两个XML列,我想在第三阵列合并这些阵列...第一个XML struxture是如何在第三阵列合并两个XML列在PHP
$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>';
从这些个XML,我想所有匹配的标签复制到新的数组中.... 我试图通过递归函数,它是要做到这一点....
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));
}
什么是您预期的输出? –
在PHP中没有* XML Array *这样的东西。你在说什么?也没有'$ this' - 请创建一个自包含的* working *示例,根据需要用尽可能少的数据和代码来演示您的问题。 – hakre
你想使用SimpleXML吗?就像hakre说的那样,没有XML数组这样的东西,但是你可以从一个数组中构建一个数组。那是你想要做什么? – Machavity