Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to parse xml without .xml extension
    primarykey
    data
    text
    <p>I cannot parse an xml from a <a href="http://iwantallftp.cloudapp.net/iisCMS-staging/api/GetApps" rel="nofollow">url</a> that does not end with the .xml extension. However using the code below i can successfully parse the same xml when saved first to /res/raw.</p> <p>Or when it is created with an .xml extension like <a href="http://www.facebook.com/l.php?u=http%3A%2F%2Firace.ph%2Ftools%2FAppAPI.xml&amp;h=NAQHBi9vE" rel="nofollow">this</a> or "api.androidhive.info/pizza/?format=xml" this for example. </p> <p>Also adding <code>/?format=xml</code> to the end of the url does not solve the problem.</p> <p>I thought that this has something to do with getting an HttpResponse but i cannot resolve the issue with my current code. I need to be able to retrieve the xml and parse it even without .xml extension.</p> <pre><code> public String getXmlFromUrl(String url) { String xml = null; try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); xml = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // return XML return xml; } public Document getDomElement(String xml){ Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); doc = db.parse(is); } catch (ParserConfigurationException e) { Log.e("Error: ", e.getMessage()); return null; } catch (SAXException e) { Log.e("Error: ", e.getMessage()); return null; } catch (IOException e) { Log.e("Error: ", e.getMessage()); return null; } return doc; } </code></pre> <p>Here are the results of my logcat:</p> <pre><code>07-25 17:54:39.090: I/INFO(29276): Content:{"Message":"An error has occurred.","ExceptionMessage":"Value cannot be null.\r\nParameter name: entity","ExceptionType":"System.ArgumentNullException","StackTrace":" at System.Data.Entity.ModelConfiguration.Utilities.RuntimeFailureMethods.Requires(Boolean condition, String userMessage, String conditionText)\r\n at System.Data.Entity.DbSet`1.Add(TEntity entity)\r\n at iisCMS.Controllers.GetAppsController.PostApp(App app)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.&lt;&gt;c__DisplayClass13.&lt;GetExecutor&gt;b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"} </code></pre> <p>When i checked the response from the server, it was <code>application/xml</code> and i think i need <code>text/xml</code> any way to convert one to the other?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload