我正在尝试从输入xml中提取值并使用groovy构造输出xml。我收到了以下错误。我举了一个小例子来验证逻辑。
def xml1 = """
<company type="bentley">
<account>
<dept1>IT</dept1>
<dept2>Admin</dept2>
<dept3>Security</dept3>
</account>
</company>""" ;
def xml2 = """
<company type="NG">
<account>
<dept1></dept1>
<dept2></dept2>
<dept3></dept3>
</account>
</company>""";
def rootnode1= new XmlParser().parseText(xml1);
def rootnode2= new XmlParser().parseText(xml2);
rootnode1.account.each {
rootnode2.account.dept1[0].value = it.dept1[0].text();
rootnode2.account.dept2[0].value = it.dept2[0].text();
}
错误:java.lang.IllegalArgumentException:参数类型不匹配
谢谢, Venkat
答案 0 :(得分:0)
看起来你需要为each
函数提供一个计数器。尝试以下内容:
if(empty($_FILES['pwd']['name']))
{
$error=array(
'error_img'=>'Image file empty !!!.'
);
$this->index();
}
else
{
$type=explode('.',$_FILES["pwd"]["name"]);
$type=$type[count($type)-1];
$url="./photos/".uniqid(rand()).'.'.$type;
if(in_array($type,array("jpg","jpeg","gif","png")))
if(is_uploaded_file($_FILES["pwd"]["tmp_name"]))
if(move_uploaded_file($_FILES["pwd"]["tmp_name"],$url))
return $url;
return "";
}
更好的是,如果你有不明数量的部门,你可以将rootnode1.account.each { n ->
rootnode2.account.dept1[0].value = n.dept1[0].text();
rootnode2.account.dept2[0].value = n.dept2[0].text();
}
移到部门级别。