0

大家好,我从 web 服务解析 Soaobject xml,然后 xml 标签不为空,一切正常,但它们是空的示例“ <barcode></barcode>”它生成字符串-anyType{}。并将其显示在我的列表中!:( 我应该怎么做才能从列表中删除这个词“anyType{}”并且它什么也没显示或我写的东西?信封.implicitTypes = false; --->这不起作用....仍然得到anyType{} ...这是我的代码:

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>

`

4

1 回答 1

0

我解决了问题,只需使用 .equals("that string")

例子

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);
                                }}}

ps如果你不使用字符串中的空间它会成为问题然后你在这个map.put(xmlelements [i],(“”))中从你的应用程序将它发送到服务所以必须改变它只是为了空间;)

没有人帮助,但我希望它对某人有所帮助;)

于 2013-02-25T14:33:48.657 回答