Skip to content

Instantly share code, notes, and snippets.

@jthmiranda
Created August 9, 2013 23:02
Show Gist options
  • Save jthmiranda/6198019 to your computer and use it in GitHub Desktop.
Save jthmiranda/6198019 to your computer and use it in GitHub Desktop.
procedure to obtain an xml attribute from webserver
URL url = new URL("http://pastebin.com/raw.php?i=RF8cL5YZ");
InputSource origin = new InputSource(url.openStream());
XPath path = XPathFactory.newInstance().newXPath();
String exp = "/a/b/c";
Node nodo = (Node) path.evaluate(exp, origin, XPathConstants.NODE);
NamedNodeMap attrs = nodo.getAttributes();
String atrib = attrs.getNamedItem("id").getNodeValue();
System.out.println(atrib);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment