Hi everyone I Parsing Soaobject xml from webservice and then xml tags are not empty there is everything ok, but then they are empty example " <barcode></barcode>
" it make string- anyType{}. and shows it in my list!
:( What i should do to remove from list this word "anyType{}" and it shows nothing or something that i write?
envelope.implicitTypes= false; ---> this is not working.... still get anyType{}...
here is my code:
String[] xmlElements={"Id","name","Unit","Cost","description","barcode"};
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
androidHttpTransport.call(SOAP_ACTION, envelope);
ArrayList<HashMap<String, String>> Tags = new ArrayList<HashMap<String, String>>();
if ( xmlelements==null&& KEY_RAKTINIS==null){
Object soapObj = (SoapObject)envelope.getResponse();
soapObj = ((SoapObject) soapObj).getProperty(KEY_PATVIRTINIMAS);
Toast.makeText(getActivity().getBaseContext(), soapObj.toString(), Toast.LENGTH_SHORT).show();
}else {
SoapObject soapObj = (SoapObject)envelope.getResponse();
soapObj = (SoapObject) soapObj.getProperty(KEY_RAKTINIS);// su situo ieinu i butent customers punkta
for (int j = 0; j < soapObj.getPropertyCount(); j++) {
SoapObject soapObjMenu = (SoapObject) soapObj.getProperty(j);
for (int i = 0; i <1; i++) {
HashMap<String, String> map = new HashMap<String, String>();
for( i=0; i < xmlelements.length;i++){
if (soapObjMenu.getProperty(xmlelements[i])!="") {
map.put(xmlelements[i], (soapObjMenu.getProperty(xmlelements[i]).toString()));
Log.v(xmlelements[i], "sitas");}
}
Tags.add(map);
}}
<Items>
<Item>
<Id>1000</Id>
<name>LCD Television HD Black 42 inches</name>
<Unit>ea</Unit>
<Cost>2000.00</Cost>
<description>Simple SKU</description>
<barcode></barcode>
</Item>
<Item>
<Id>1001</Id>
<name>LCD Television Model 01</name>
<Unit>ea</Unit>
<Cost>4015.00</Cost>
<description></description>
<barcode></barcode>
</Item>
<Item>
<Id>1003</Id>
<name>Plasma Television Model 01</name>
<Unit>ea</Unit>
<Cost>4020.00</Cost>
<description></description>
<barcode></barcode>
</Item>
`
I solved problem just use .equals("that string ")
Example
HashMap<String, String> map = new HashMap<String, String>();
for( i=0; i < xmlelements.length;i++){
if (!soapObjMenu.getProperty(xmlelements[i]).toString().equals("anyType{}")){ // use when tag is empty...
map.put(xmlelements[i], (soapObjMenu.getProperty(xmlelements[i]).toString()));}else{ map.put(xmlelements[i], (" "));}
}
Tags.add(map);
}}}
p.s. if you won't use space in string it becomes problem then you send it to service from your app in this map.put(xmlelements[i], (" ")) so must change it just for space ;)
Nobody helped but i hope it helps for somebody ;)