एंड्रॉइड 4.0 एपीआई में डोम पार्सर

मेरी समस्या है कि डोम पार्सर एंड्रॉइड 4.0 में काम नहीं कर रहा है, लेकिन यह 2.2 पर काम कर रहा है, अगर मैं अपने 4.0 एम्यूलेटर में प्रोजेक्ट चलाता हूं तो नीचे की रेखा निष्पादित नहीं होती है और यह कोई त्रुटि नहीं देती है।

Document doc = db.parse(inStream);

मेरा जावा कोड निम्नलिखित है: -

public class TestParsingActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        StringBuffer sb = new StringBuffer();

        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);

        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", "192.168.1.220");
        System.setProperty("http.proxyPort", "315");

        String NAMESPACE = "Dipak";
        String SOAP_ACTION = "Dipak/Start";
        String METHOD_NAME = "Start";
        String url = "http://google.co.uk/Dip/service1.asmx";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo p = new PropertyInfo();
        String qry = "select Password from Profiles where ID = (select uid from userprofiles where name = 'Dipak')";

        p.setName("SQL");
        p.setValue(qry);
        request.addProperty(p);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(url);
        httpTransport.debug = true;

        System.out.println("three**************");

        try {
            httpTransport.call(SOAP_ACTION, envelope);
            System.out.println("four**************");
           //SoapObject response=(SoapObject)envelope.bodyIn;
            SoapObject response = (SoapObject) envelope.getResponse();

            System.out.println("response =====>>>> "
                    + response.getProperty(0).toString());
           //SoapObject response=(SoapObject)envelope.getResponse();
           //SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            System.out.println("success**************");

            sb.append(response);
            System.out.println("Data from Search Job =====>>>> "
                    + sb.toString());
           //return response.toString();

        } catch (IOException e) {
           //TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
           //TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory
                    .newInstance();

            DocumentBuilder db = factory.newDocumentBuilder();
            InputSource inStream = new InputSource();

            System.out.println("Data from try  =====>>>> " + sb.toString());

            inStream.setCharacterStream(new StringReader(sb.toString()));

            System.out
                    .println("Data from try  =====>>>>11111111111111111111111111111 ");

            Document doc = db.parse(inStream);
            System.out
                    .println("Data from try  =====>>>>22222222222222222222222222222 ");

            Element root = doc.getDocumentElement();

            String root1 = doc.getTextContent();
            System.out
                    .println("Value of root................................................................................"
                            + root);
            System.out
                    .println("Value of root1................................................................................"
                            + root1);
            System.out
                    .println("................................................................................5");
        } catch (Exception e) {
           //TODO: handle exception
        }

    }
}

किसी भी मदद की सराहना की जाएगी, मेरे खराब अंग्रेजी संचार के लिए खेद है।

1
जोड़ा संपादित
विचारों: 1

1 उत्तर

आप इसका उपयोग क्यों नहीं करते

response.getPropertyAsString(index);

या

response.getPropertyAsString("PROPERTY_NAME");

?

But you still would like to use Dom parser, you can use HttpTranspयाtSE.responseDump to get response in xml fयाmat and try parsing xml instead of ksaop2's response fयाmat.

0
जोड़ा
कृपया कुछ स्पष्टीकरण दें या यदि आपके पास कोई उदाहरण लिंक है तो कृपया मुझे दें।
जोड़ा लेखक Dipak Keshariya, स्रोत
धन्यवाद जेपीरीस्ट, मेरी समस्या हल हो गई है।
जोड़ा लेखक Dipak Keshariya, स्रोत