Java tutorial
//package com.java2s; import java.net.URI; import java.net.URISyntaxException; import org.w3c.dom.Element; public class Main { public static URI getURIAttribute(Element el, String attr, URI defaultValue) { if (el.hasAttribute(attr)) { try { return new URI(el.getAttribute(attr)); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return defaultValue; } }