0
votes

Hi so im loocking to extract all value from the Rows compenemnt and create variables with it .. here what i did till now any help will be considerable .

And here my xml file

enter image description here

def xml = row.get('HttpResponse'); def AMC = new 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;`
1
What is the problem with your attempt? Please add the error you get or how the result is unexpected. Please don't use screenshots, where text would do. We can not search in or copy from screenshots. - cfrick
I think you want to create a list having key names from Columns and values from Rows, eg [Id:'CA|CP...', Text:'G0E 1V0', Highlight: '0-3,4-7', Cursor:'0'] and so on. Is that right? - Catalin

1 Answers

0
votes

Thanks Catalin for your answer but I resolved it this way:

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;

But another question what should i do to create a variable with only a part of the variable id . For example Id="CA|CP|ENG|1V0-G0E" I want to separate the list.

Something like

Var x= CA
Var y= CP
....