cancel
Showing results for 
Search instead for 
Did you mean: 

Java code to parse the content of input XML and send to target field

Former Member
0 Kudos

HI All,

I have the following UDF code which will parse the input XML and send some portion to the target element

String temp = a[0].substring(a[0].indexOf(b[0])+(b[0].length()));

String value = temp.substring(0,temp.indexOf("/")-2);

result.addValue(value);

Actual input should come is value="149433" /. Now the present input doesn't contain space after quotation symbol (value="149433"/)which is truncating the last digit(The output going is 14943 instead of 149433)

The above UDF will remove the last 2 characters and send the output to target field. The new requirement is the entire value should send to target field. Please advise how to achieve the requirement(with space&quotation, without space and with quotation)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Not sure what's the context of argument "b", but u can replace second line of ur code with the below one:

String value = a[0].replaceAll(" ","").substring(0,a[0].replaceAll(" ","").indexOf("/")-1);

So above statement will replace all the spaces present in the input value and then pass that value which is present before "/" (without any spaces)

Thanks

Amit Srivastava

Former Member
0 Kudos

HI Amit,

Thanks, but its not working

Former Member
0 Kudos

Hello,

I have tested this code before pasting it here, so i am not sure what's not working for u?

As stated above, the code will remove all the spaces and only output the digits present before  "/".

String value = temp.replaceAll(" ","").substring(0,temp.replaceAll(" ","").indexOf("/")-1);

Edited: Since u are performing some operation on input value a[0] in the first line of ur code so instead of a[0] use temp.

Thanks

Amit Srivastava

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Suresh,

You can use this code:

String value = temp.substring(0,temp.lastIndexOf("/"));


Regards,

Mark