Hi Gurus,
My issue is simple but per my poor Java knowledge I am not able to work on this.
I have this structure as string:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:VFMDesSendRemitoResponse xmlns:ns2="http://ws.monsanto.verifarma.bdev.com.ar/">
<return>
<codOperac>41</codOperac>
<errors>
<description>el valor 30-00000000-7 para el campo cuit dest es invalido.</description>
<errorCode>-11</errorCode>
</errors>
<errors>
<description>el valor 30-00000000-7 para el campo cuit ship es invalido.</description>
<errorCode>-11</errorCode>
</errors>
<errors>
<description>el campo almacen no puede estar vacio</description>
<errorCode>-18</errorCode>
</errors>
<errors>
<description>la fecha 20140206 posee un valor invalido. Formato valido: yyyy-MM-dd</description>
<errorCode>-19</errorCode>
</errors>
<errors>
<description>la fecha 20140206 posee un valor invalido. Formato valido: yyyy-MM-dd</description>
<errorCode>-19</errorCode>
</errors>
<errors>
<description>el valor 1122 - null para el campo dep?sito es invalido.</description>
<errorCode>-11</errorCode>
</errors>
<status>ERR</status></return>
</ns2:VFMDesSendRemitoResponse></soap:Body></soap:Envelope>
And I want to split it into next structure:
<errors> (0..unbounded)
<description> (0..1)
</description>
<errorCode> (0..1)
</errorCode>
</errors>
I have an old UDF with this code:
String empty = "<" + tag[0] + "/>";
String begin = "<" + tag[0] + ">";
String end = "</" + tag[0] + ">";
String data = input[0];
do {
int i = data.indexOf(tag[0]);
if (i < 1) break; else i--;
if (data.substring(i, i+empty.length()).equals(empty)) {
result.addValue(""); //empty
data = data.substring(i+empty.length());
}
else {
data = data.substring(i+begin.length());
int endIndex = data.indexOf(end);
result.addValue(data.substring(0, endIndex));
data = data.substring(endIndex + end.length());
}
} while (data.length() > empty.length());
But it is only sending data for the first "errors" segment created and all the others are dismissed.
Is anyone able to help me correcting this code to send data to ALL errors segments?
Thanks!