Mirth之取特定的xml报文节点

入参xml报文:(PriKeyList的节点是不确定的)


    TJ401
    
        V41
        
            
                
                    20598888
                
            
            
                
                    20590818
                    1
                
                
                    20590818
                    2
                
                
                    20590818
                    3
                
                
                    20590818
                    4
                      
            
        
    

如何取特定的xml节点具体代码

//遍历提取xnl节点所有报文数据:
var xml = new XML(msg);
var num =  xml.ListInfo.ListRow.OUTP_TREAT_REC.PriKeyList.length();
$c("num",num);
var SERIAL_NO=msg['ListInfo']['ListRow']['OUTP_TREAT_REC']['PriKeyList'][0]['SERIAL_NO'].toString();
 $c("SERIAL_NO",SERIAL_NO);
var i =0;
while(i<=(num-1)){
	var ITEM_NO=msg['ListInfo']['ListRow']['OUTP_TREAT_REC']['PriKeyList'][i]['ITEM_NO'].toString();
	var sql="select count(*) from hiip.v_tj401_xytx t where t.treatment_apply_no='"+SERIAL_NO+"' and t.ITEM_NO='"+ITEM_NO+"' ";
	 $c("sql"+i,sql);
	var resultcount1=GetSelect(sql, "HIS");
	while(resultcount1.next()){
	var resultcount = resultcount1.getString(1)==null?"":resultcount1 .getString(1) ;   
	 $c("resultcount",resultcount); 
	if(resultcount==1){
		$c("resultcount",resultcount);
		var tempxml=new XML("");
          tempxml['EventType']="TJ401";
          var tempListInfo=new XML("");
          tempListInfo['ActionType']="V41";
          var tempListRow=new XML("");
          var tempOUTP_ORDERS=new XML("");
          var tempPriKeyList=new XML("");
          tempPriKeyList['SERIAL_NO']=SERIAL_NO;
          tempOUTP_ORDERS.appendChild(tempPriKeyList);
          tempListRow.appendChild(tempOUTP_ORDERS);
          var tempOUTP_TREAT_REC=new XML("");
          var tempPriKeyList_0=new XML("");
          tempPriKeyList_0['SERIAL_NO']=SERIAL_NO;
          tempPriKeyList_0['ITEM_NO']=ITEM_NO;
          tempOUTP_TREAT_REC.appendChild(tempPriKeyList_0);
          tempListRow.appendChild(tempOUTP_TREAT_REC);
          tempListInfo.appendChild(tempListRow);
          tempxml.appendChild(tempListInfo);
          $c("tempxml",tempxml);
          $c("router","success_to_TreatmentInfoAdd");
          var ret=router.routeMessage("TreatmentInfoAdd", tempxml);
		}
   }
	i++;
}

你可能感兴趣的:(Mirth,xml,数学建模)