我正在尝试使用我的数据库的Android应用程序。我知道如何检索和发送信息到数据库,但我不知道如何在Android中执行此操作。 当我输入网址时,在浏览器中输入“http://01.01.001.001/api/example”,我可以看到:
<ArrayOfArrayOfstring xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<ArrayOfstring>
<string>52</string>
<string>Pregunta español prueba 52</string>
<string>NO</string>
<string>SI</string>
<string>NO</string>
<string/>
<string/>
<string/>
<string/>
<string/>
<string/>
<string/>
<string i:nil="true"/>
</ArrayOfstring>
<ArrayOfstring>
<string>53</string>
<string>Pregunta 53 NIVEL 2</string>
<string>NO</string>
<string>53 mucho</string>
<string>53 Algo</string>
<string>53 Nada</string>
<string>53 Poco</string>
<string>53 Fin</string>
<string i:nil="true"/>
<string i:nil="true"/>
<string i:nil="true"/>
<string i:nil="true"/>
<string i:nil="true"/>
</ArrayOfstring>
这是一串字符串。如何将每个字符串放在android中的变量中?如果我试试
public static InputStream getInputStreamFromUrl(String url) {
InputStream content = null;
try {
HttpGet httpGet = new HttpGet(url);
HttpClient httpclient = new DefaultHttpClient();
// Execute HTTP Get Request
HttpResponse response = httpclient.execute(httpGet);
content = response.getEntity().getContent();
} catch (Exception e) {
//handle the exception !
}
return content;
}
使用URL时,内容始终为null。一旦内容不为null,我该如何将其翻译成一组字符串?
非常感谢!