文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>FLEX 合并两个XML的属性

FLEX 合并两个XML的属性

时间:2011-03-10  来源:春哥也编程

例如:

oldXml

<object datePoint="2011-03-05" PT_staticCount="3" UOC_staticCount="3"/>
<object datePoint="2011-03-06" PT_staticCount="5" UOC_staticCount="9"/>
<object datePoint="2011-03-07" PT_staticCount="9" UOC_staticCount="7"/>
<object datePoint="2011-03-08" PT_staticCount="15" UOC_staticCount="9"/>
<object datePoint="2011-03-09" PT_staticCount="6" UOC_staticCount="5"/>
<object datePoint="2011-03-10" PT_staticCount="6" UOC_staticCount="4"/>

newXml

<object datePoint="2011-03-05" UOC_staticCount="3"/>
<object datePoint="2011-03-06" UOC_staticCount="9"/>
<object datePoint="2011-03-07" UOC_staticCount="7"/>
<object datePoint="2011-03-08" UOC_staticCount="9"/>
<object datePoint="2011-03-09" UOC_staticCount="5"/>
<object datePoint="2011-03-10" UOC_staticCount="4"/>

可以是用如下函数进行合并

private function mergeTwoXml(oldXml:XMLList, newXml:XMLList, propertyInNewXMl:String):XMLList
{
        for(var i:int = 0; i < oldXml.length(); i++)
        {
                oldXml[i].@[propertyInNewXMl+"_staticCount"] = newXml[i].attribute(propertyInNewXMl+"_staticCount");
        }
    return oldXml;
}

输出的内容为:

<object datePoint="2011-03-05" PT_staticCount="3" UOC_staticCount="3"/>
<object datePoint="2011-03-06" PT_staticCount="5" UOC_staticCount="9"/>
<object datePoint="2011-03-07" PT_staticCount="9" UOC_staticCount="7"/>
<object datePoint="2011-03-08" PT_staticCount="15" UOC_staticCount="9"/>
<object datePoint="2011-03-09" PT_staticCount="6" UOC_staticCount="5"/>
<object datePoint="2011-03-10" PT_staticCount="6" UOC_staticCount="4"/>
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载