DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = domFactory.newDocumentBuilder();
StringReader reader = new StringReader(error);
Document doc = builder.parse(new InputSource(reader));
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String method = (String) xpath
.evaluate("/Error/@Method", doc, XPathConstants.STRING);
String calaisRequestID = (String) xpath
.evaluate("/Error/@calaisRequestID", doc, XPathConstants.STRING);
String creationDate = (String) xpath
.evaluate("/Error/@CreationDate", doc, XPathConstants.STRING);
String calaisVersion = (String) xpath
.evaluate("/Error/@CalaisVersion", doc, XPathConstants.STRING);
String exception = (String) xpath
.evaluate("/Error/Exception/text()", doc, XPathConstants.STRING);
return new CalaisException(method, calaisRequestID, creationDate,
calaisVersion, exception);
} catch (Exception e) {
throw new RuntimeException("Unable to parse exception", e);