java – XPath to parse JAX-RS result – Education Career Blog

I don’t know how to use XPath so I can parse the result of the XML I got from JAX-RS and put it into an ArrayList or something, here’s the code I have so far, it generates a String… but I want to be able to use XPath to parse it, as it’s better to parse XML rather than parsing String.

private Client client = Client.create();
    private List<String> venueName = new ArrayList<String>();

    private String getNearbyVenues(double lattitude, double longitude){
        WebResource webResource = client.resource("http://api.foursquare.com/v1/venues");
        MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
        queryParams.add("geolat", String.valueOf(lattitude));
        queryParams.add("geolong", String.valueOf(longitude));
        return webResource.queryParams(queryParams).get(String.class);
    }

The result goes something like this

,

Below is an answer of mine to another question that explains how to use the Java SE javax.xml.xpath libraries:

Leave a Comment