Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parse the XML response and read the userid and store them in a list

0683p000009MGjO.png 

I am trying to read the xml response from tRRestClient2 and 
here is my code from tJavaRow_2

java.util.List<String> list2 = java.util.ArrayList<String>)globalMap.get("list");
java.util.Collections.sort(list2);
System.out.println("#1 iterator");
String lastElement= new String();
java.util.Iterator<String> iterator = list2.iterator();

while (iterator.hasNext()) {
System.out.println(iterator.next());
}

Here is the code in tJavaFlex_1
===================
start code
-------------
java.util.List<String> mylist = java.util.ArrayList<String>)globalMap.get("list");;
System.out.println("Start");

main code
------------

mylist.add(row5.UserID);

End code
------------
globalMap.put("list",mylist);


here is the output
========================

--------------------------------------
Start
#1 iterator
235384
Start
#1 iterator
235384
246456
Start
#1 iterator
234551
235384
246456
...........



I want to get hold of just the arrayList in my tJavaRow and do further processing of the data.
How can I achieve that? I just want my arrayList with all my userIDs and then do further data processing on it.

Please advise.

Labels (2)
4 Replies
Anonymous
Not applicable
Author

Any help? Please.
Anonymous
Not applicable
Author

Hi 
I don't understand why you iterate each row after tExtractXMLField? To me, if you just want to put all user ID to a list, and then  do further data processing on it, the job design looks like:
....tExtractXMLField--main--tJavaFlex--oncomponentok--tJava


// use tJava instead of tJavaRow component.
Anonymous
Not applicable
Author

Thanks Shong.It works fine.Can you please explain as why I need to replace tJavaRow with tJava?
Anonymous
Not applicable
Author

Hi 
Because it does not requires an input data flow and generates an output data flow in your case, I would recommend you to read this KB article to know more the difference between tJava and tJavaFlex.