Source:
private static String parseRegistrationResponse(HttpResponse response, Boolean isFailure) throws IllegalStateException, SAXException, IOException, ParserConfigurationException, DeviceRegistrationFailedException { HttpEntity entity = response.getEntity(); if (entity != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); factory.setFeature("<LINK_0>", true); } catch (Exception e) { Log.warn("failed to enable xml safe feature"); } DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(entity.getContent()); document.getDocumentElement().normalize(); Node root = document.getDocumentElement(); NodeList children = root.getChildNodes(); String errorSubCode = null; DeviceRegistrationErrorCode errorCode = null; Node node = null; for (int i = 0; i < children.getLength(); i++) { node = children.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } if (node.getNodeName().equalsIgnoreCase("PUID")) { return node.getTextContent(); } if (isFailure) { if (node.getNodeName().equalsIgnoreCase("ERROR")) { errorCode = DeviceRegistrationErrorCode.Unknown; NamedNodeMap attributes = node.getAttributes(); String codeLabel = attributes.getNamedItem("Code").getTextContent(); if (codeLabel != null && codeLabel.startsWith("dc")) { int code = Integer.parseInt(codeLabel.substring(2)); errorCode = TranslateErrorCode(code); } } if (node.getNodeName().equalsIgnoreCase("ERRORSUBCODE")) { errorSubCode = node.getTextContent(); } } } if (isFailure) { throw new DeviceRegistrationFailedException(errorCode, errorSubCode); } } return null; }

Target:
private static String parseRegistrationResponse(HttpResponse response, Boolean isFailure) throws IllegalStateException, SAXException, IOException, ParserConfigurationException, DeviceRegistrationFailedException { HttpEntity entity = response.getEntity(); if (entity != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); factory.setFeature("<LINK_0>", true); } catch (Exception e) { Log.warn("failed to enable xml safe feature"); } DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(entity.getContent()); document.getDocumentElement().normalize(); Node root = document.getDocumentElement(); NodeList children = root.getChildNodes(); String errorSubCode = null; DeviceRegistrationErrorCode errorCode = null; Node node = null; for (int i = 0; i < children.getLength(); i++) { node = children.item(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } if ("PUID".equalsIgnoreCase(node.getNodeName())) { return node.getTextContent(); } if (isFailure) { if ("ERROR".equalsIgnoreCase(node.getNodeName())) { errorCode = DeviceRegistrationErrorCode.Unknown; NamedNodeMap attributes = node.getAttributes(); String codeLabel = attributes.getNamedItem("Code").getTextContent(); if (codeLabel != null && codeLabel.startsWith("dc")) { int code = Integer.parseInt(codeLabel.substring(2)); errorCode = TranslateErrorCode(code); } } if ("ERRORSUBCODE".equalsIgnoreCase(node.getNodeName())) { errorSubCode = node.getTextContent(); } } } if (isFailure) { throw new DeviceRegistrationFailedException(errorCode, errorSubCode); } } return null; }