I have a web service which returns an XML file like this:
<Service>
<id>12</id>
<function_code>2</function_code>
<cf>AABBBCCCAAA</cf>
<active>0</active>
<option>resume_state</option>
</Service>
In many case the element may be not returned, and the XML will be:
<Service>
<id>12</id>
<function_code>2</function_code>
<cf>AABBBCCCAAA</cf>
<active>0</active>
<option/>
</Service>
I'm parsing this element with the following code:
String id = response.getProperty("cf").toString();
String func= response.getProperty("function_code").toString();
int active = Integer.parseInt(response.getProperty("active").toString();
String option = response.getProperty("option").toString();
where response is SoapObject.
In this situation, when I try to print the option String on error line:
System.err.println("my option variable contains: "+option);
The result is:
my option variable contains anyType{}
Why? And what can I do for parsing the option string obtaining null value if the option element is void () ?