Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing check-in XML from google places api
    primarykey
    data
    text
    <p>I am trying to fetch checkin locations from Google places API but I am getting error for XML FileNotFoundException when I try to read it through url.openStream(). My key is correct because I tried using it in some other URL in browser. If someone has used this feature then please let me know how to do this. Here is my code:</p> <pre><code> public String checkingMessage() { String strURL = "https://maps.googleapis.com/maps/api/place/check-in/xml?sensor=true&amp;key=" + GOOGLE_API_KEY; URL url; try { url = new URL(strURL.replace(" ", "%20")); // Standard of reading a XML file DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder; Document doc = null; XPathExpression expr = null; builder = factory.newDocumentBuilder(); doc = builder.parse(new InputSource(url.openStream())); // Create a XPathFactory XPathFactory xFactory = XPathFactory.newInstance(); // Create a XPath object XPath xpath = xFactory.newXPath(); // Compile the XPath expression expr = xpath.compile("//reference/text()"); // Run the query and get a nodeset Object result = expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes = (NodeList) result; String answer = nodes.item(0).getNodeValue(); Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG); }catch(Exception ex){ ex.printStackTrace(); } return null; } </code></pre> <p>If I use direct url in browser, I get following error:</p> <pre><code>400: Your client has issued a malformed or illegal request. That’s all we know. </code></pre> <p>I dont know json parsing, so I am using XML. Output I believe should be like this, hence I am trying to fetch value of reference:</p> <pre><code> &lt;CheckInRequest&gt; &lt;reference&gt;place_reference&lt;/reference&gt; &lt;/CheckInRequest&gt; </code></pre> <p>Update : I tried using HttpResponse and get response into Entity as follows</p> <pre><code>if (httpResponse.getStatusLine().getStatusCode() == 200){ strResult = EntityUtils.toString(httpResponse.getEntity()); } </code></pre> <p>But then I get MalFormedException on </p> <pre><code>doc = builder.parse(strResult); // doc is Document type </code></pre> <p>Either ways how can I get xml result into doc</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