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>
및 2 인 배열은 ....
이 XMLS에서$old = '<forms id="frm16648">
<group ref="" id="tarascioheader" mode="block">
<label>
<![CDATA[abc]]>
</label>
</group>
</forms>':
</group>
</forms>';
, 난 .... 새로운 배열에 I는 재귀 함수에 의해이 작업을 수행하려고를 일치하는 모든 태그를 복사 할 것입니다
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 Arrays * 같은 것이 없습니다. 너 무슨 소리 야? 또한 '$ this'가 없습니다 - 필요한만큼 작은 데이터와 코드로 문제를 설명하는 독립적 인 * 작업 예제를 만드십시오. – hakre
SimpleXML을 사용하려고합니까? hakre가 말했듯이 XML 배열과 같은 것은 없지만 하나의 배열을 만들 수 있습니다. 그게 당신이하려는 일 이니? – Machavity