zoukankan      html  css  js  c++  java
  • FLEX 合并两个XML的属性

    例如:

    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"/>
    
  • 相关阅读:
    mongodb一个关键字对多个字段同时查询,mongodb $or $and查询
    用Supervisord管理Python进程
    ImportError No module named memcache
    eclipse项目显示标尺
    Eclipse 安装插件后不显示的解决办法
    Flutter入门到放弃笔记(一)--Mac电脑配置Flutter环境
    iOS 动态库、静态库相关
    iOS 获取手机后台音频状态以及类别
    Swift 懒加载
    Swift中@ojbc 重载用法
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1979900.html
Copyright © 2011-2022 走看看