@Put public void store(DomRepresentation mailRep) { // Retrieve the XML element using XPath expressions String status = mailRep.getText("/mail/status"); String subject = mailRep.getText("/mail/subject"); String content = mailRep.getText("/mail/content"); String accountRef = mailRep.getText("/mail/accountRef"); // Output the XML element values System.out.println("Status: " + status); System.out.println("Subject: " + subject); System.out.println("Content: " + content); System.out.println("Account URI: " + accountRef); }
/** * @param subPath * @throws IOException * @throws DOMException */ private void getAndCheckJaxb(String subPath) throws Exception { Response response = get(subPath); assertEquals(Status.SUCCESS_OK, response.getStatus()); DomRepresentation entity = new DomRepresentation(response.getEntity()); Node xml = entity.getDocument().getFirstChild(); System.out.println(subPath + ": " + entity.getText()); assertEquals("person", xml.getNodeName()); NodeList nodeList = xml.getChildNodes(); Node node = nodeList.item(0); assertEquals("firstname", node.getNodeName()); assertEquals("Angela", node.getFirstChild().getNodeValue()); node = nodeList.item(1); assertEquals("lastname", node.getNodeName()); assertEquals("Merkel", node.getFirstChild().getNodeValue()); assertEquals(2, nodeList.getLength()); }