急!我如何在android手机端解析webservice返回的dataset数据啊?急用。在线等待。有用功的吗

解决方案 »

  1.   

      <?xml version="1.0" encoding="utf-8" ?> 
    - <DataSet xmlns="http://tempuri.org/">
    - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    - <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="">
    - <xs:complexType>
    - <xs:choice minOccurs="0" maxOccurs="unbounded">
    - <xs:element name="Table">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="ID" type="xs:int" minOccurs="0" /> 
      <xs:element name="Code" type="xs:string" minOccurs="0" /> 
      <xs:element name="Title" type="xs:string" minOccurs="0" /> 
      <xs:element name="Law" type="xs:string" minOccurs="0" /> 
      <xs:element name="LawCatalog" type="xs:string" minOccurs="0" /> 
      <xs:element name="Content" type="xs:string" minOccurs="0" /> 
      <xs:element name="OrderIndex" type="xs:int" minOccurs="0" /> 
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:schema>
    - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    - <NewDataSet xmlns="">
    - <Table diffgr:id="Table1" msdata:rowOrder="0">
      <ID>1</ID> 
      <Code>lawitem001</Code> 
      <Title>第一条</Title> 
      <Law>law001</Law> 
      <LawCatalog>law001</LawCatalog> 
      <Content>为了加强城市市容和环境卫生管理,创造清洁、优美的城市工作、生活环境,促进城市社会主义物质文明和精神文明建设,制定本条例。</Content> 
      <OrderIndex>1</OrderIndex> 
      </Table>
    - <Table diffgr:id="Table2" msdata:rowOrder="1">
      <ID>2</ID> 
      <Code>lawitem002</Code> 
      <Title>第二条</Title> 
      <Law>law001</Law> 
      <LawCatalog>law001</LawCatalog> 
      <Content>在中华人民共和国城市内,一切单位和个人都必须遵守本条例。</Content> 
      <OrderIndex>2</OrderIndex> 
      </Table>
    - <Table diffgr:id="Table3" msdata:rowOrder="2">
      <ID>3</ID> 
      <Code>lawitem003</Code> 
      <Title>第三条</Title> 
      <Law>law001</Law> 
      <LawCatalog>law001</LawCatalog> 
      <Content>城市市容和环境卫生工作,实行统一领导、分区负责、专业人员管理与群众管理相结合的原则。</Content> 
      <OrderIndex>3</OrderIndex> 
      </Table>
    </NewDataSet>
      </diffgr:diffgram>
      </DataSet>格式是这样的。谢谢了 有什么办法啊
      

  2.   

    我光会解析字符串 这样的dataset不会解析
      

  3.   

    detail = (SoapObject) result.getProperty("getStationNameResult");
               
                if (detail.getName()=="anyType")
                {
                 for (int i = 0; i < detail.getPropertyCount(); i++) {
    SoapObject sopObject = (SoapObject) detail.getProperty(i);
    strName = sopObject.getProperty(0).toString();
    strCode = sopObject.getProperty(1).toString();
    currentStation = new Station();
    currentStation.setStationName(strName);
    currentStation.setStationShort(strCode);
    listStations.add(currentStation);
    }
                } 
      

  4.   

    lz  调用webservice  成功的列子可不可以看下
      

  5.   

    先取得Table節點的集合
    然后篇歷
    分別取得各節點的值就好了
      

  6.   

           SoapObject so=(SoapObject)rpc.getProperty(1);
           System.out.println("username:"+getReturnValueByFieldName(so,"f_username"));
           String st=getReturnValueByFieldName(so,"f_username");
           if(st!=null){
             Toast.makeText(MoveActivity.this, st,Toast.LENGTH_LONG).show();
                 Intent intent=new Intent();
    //             intent.putExtra("name", st);
            intent.setClass(MoveActivity.this, MoveSy.class);
            MoveActivity.this.startActivity(intent);
            
           }
       public static String getReturnValueByFieldName(SoapObject so,String keytobefind)
        {
    String returnValue="";
    HashMap<String, String> keyIndexMapping =new HashMap();
       keyIndexMapping.put("id","0");
       keyIndexMapping.put("f_username","1");
       int indexInReturn=Integer.parseInt(""+keyIndexMapping.get(keytobefind));
       returnValue=so.getProperty(indexInReturn).toString();
        return returnValue;
        }
      

  7.   

    if (envelope.getResponse() != null) {
    SoapObject soapObject = (SoapObject) envelope.bodyIn;
    for (int i = 0; i < soapObject.getPropertyCount(); i++) {
    SoapObject soap1 = (SoapObject) soapObject.getProperty(i);
    for (int j = 0; j < soap1.getPropertyCount(); j++) {
    System.out.println(soap1.getProperty(j).toString())
    }
    }
    }
    根据xml 的格式,多遍历几次就出来了
      

  8.   

    参照这篇文章:Android Webservices 返回多行多列数据(Dataset) 
    http://blog.csdn.net/sheshou2/article/details/6298542
      

  9.   

    解决了 自己解析的xml文件
      

  10.   

    楼主使用那个什么方式解析的sax还是xstream还是别的~求解答~