大家好,我很乐意从Rows组件中提取所有值并使用它创建变量..在这里,我到目前为止所做的任何工作都是相当大的。
这是我的xml文件
def xml = row.get('HttpResponse'); def AMC =新的XmlSlurper()。parseText(xml); def allRecords = AMC.Table;
List newAddressList=new ArrayList();
for (int i=0; i < AMC.Columns.size(); i++){
String Id = AMC.Table[i].Rows.Row.Id;
String Text = AMC.Table[i].Rows.Row.Text;
String Highlight = AMC.Table[i].Rows.Row.Highlight;
String Cursor = AMC.Table[i].Rows.Row.Cursor;
newAddressList.add(['Id':Id,'Text':Text,'Highlight':description,'Cursor':Cursor]);
}
data['AddressIndexList'] = newAddressList;`
Thx Catalin为您解答,但我这样解决:
def str = row.get('HttpResponse');
def xml = new XmlParser().parseText(str)
def id = xml.Rows[0].Row[0].@Id
def Text = xml.Rows[0].Row[0].@Text
def Highlight = xml.Rows[0].Row[0].@Highlight
def Description = xml.Rows[0].Row[0].@Description
data['id'] = id;
data['Text'] = Text;
data['Highlight'] = Highlight;
data['Description'] = Description;
但是另一个问题是我应该怎么做才能创建一个仅包含变量id一部分的变量。例如,Id =“ CA | CP | ENG | 1V0-G0E”我希望将列表分开。类似于Var x = CA Var y = CP ....
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句