用于解析 JAX-RS 结果的 XPath
我不知道如何使用 XPath,所以我可以解析从 JAX-RS 获得的 XML 结果并将其放入 ArrayList 或其他内容中,这是我到目前为止的代码,它生成一个字符串...但是我希望能够使用 XPath 来解析它,因为解析 XML 比解析 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);
}
结果类似于这个
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是我对另一个问题的回答,解释了如何使用 Java SE javax.xml.xpath 库:
Below is an answer of mine to another question that explains how to use the Java SE javax.xml.xpath libraries: