} else {
// Fetch a resource: an XML document full of search results
String term = Reference.encode(args[0]);
String uri = BASE_URI + "?appid=restbook&query=" + term;
Representation entity = new ClientResource(uri).get();
DomRepresentation document = new DomRepresentation(entity);
// Associate the namespace with the prefix y
document.setNamespaceAware(true);
document.getNamespaces().put("y", "urn:yahoo:srch");
// Use XPath to find the interesting parts of the data structure
String expr = "/y:ResultSet/y:Result/y:Title/text()";
for (Node node : document.getNodes(expr)) {
System.out.println(node.getTextContent());
}
}
}