/** * Parse an XML string as DOM. */ public static Document fromString(String xml) { try { return fromInputStream( new ByteArrayInputStream(xml.getBytes("utf-8")), "utf-8" ); } catch(UnsupportedEncodingException e) { throw new RuntimeException(e); } }
/** * Parses an XML string as DOM. * * @param xml the input XML string * @return the parsed XML DOM root. */ public static Document fromString(String xml) { try { return fromInputStream( new ByteArrayInputStream(xml.getBytes("utf-8")), "utf-8" ); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
/** * Parses an XML string as DOM. * * @param xml the input XML string * @return the parsed XML DOM root. */ public static Document fromString(String xml) { try { return fromInputStream( new ByteArrayInputStream(xml.getBytes("utf-8")), "utf-8" ); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
/** * Parses an XML string as DOM. * * @param xml the input XML string * @return the parsed XML DOM root. */ public static Document fromString(String xml) { try { return fromInputStream( new ByteArrayInputStream(xml.getBytes("utf-8")), "utf-8" ); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@Override protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception { return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null)); } }
@Override protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception { return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null)); } }
@Override protected Document parse(Http.RequestHeader request, ByteString bytes) throws Exception { return XML.fromInputStream(bytes.iterator().asInputStream(), request.charset().orElse(null)); } }
/** * Get the response body as a {@link Document DOM document} * @return a DOM document */ public Document asXml() { try { return play.libs.XML.fromInputStream(ahcResponse.getResponseBodyAsStream(), "utf-8"); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Get the response body as a {@link Document DOM document} * * @return a DOM document */ @Override public Document asXml() { String contentType = contentType(); Charset charset = HttpUtils.parseCharset(contentType); if (charset == null) { charset = StandardCharsets.UTF_8; } return play.libs.XML.fromInputStream(ahcResponse.getResponseBodyAsStream(), charset.name()); }