@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
Document document = node.getOwnerDocument(); DOMImplementationLS domImplLS = (DOMImplementationLS) document .getImplementation(); LSSerializer serializer = domImplLS.createLSSerializer(); String str = serializer.writeToString(node);
public String getStringFromDoc(org.w3c.dom.Document doc) { DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation(); LSSerializer lsSerializer = domImplementation.createLSSerializer(); return lsSerializer.writeToString(doc); }
public String innerXml(Node node) { DOMImplementationLS lsImpl = (DOMImplementationLS)node.getOwnerDocument().getImplementation().getFeature("LS", "3.0"); LSSerializer lsSerializer = lsImpl.createLSSerializer(); NodeList childNodes = node.getChildNodes(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < childNodes.getLength(); i++) { sb.append(lsSerializer.writeToString(childNodes.item(i))); } return sb.toString(); }
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
private String elementToString(Element root) { DOMImplementationLS domImplLS = (DOMImplementationLS) root.getOwnerDocument().getImplementation(); return domImplLS.createLSSerializer().writeToString(root); } }
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
writer.getDomConfig().setParameter("xml-declaration", keepDeclaration); // Set this to true if the declaration is needed to be outputted. return writer.writeToString(document); } catch (Exception e) { throw new RuntimeException(e);
private static String serialize(DOMImplementation domImpl, Document document) { DOMImplementationLS ls = (DOMImplementationLS)domImpl; LSSerializer lss = ls.createLSSerializer(); return lss.writeToString(document); } }
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
public static String elementToString(Element el) { if (el == null) return ""; Document document = el.getOwnerDocument(); DOMImplementationLS domImplLS = (DOMImplementationLS) document .getImplementation(); LSSerializer serializer = domImplLS.createLSSerializer(); return serializer.writeToString(el); }
public static String elementToString(Element el) { if (el == null) return ""; Document document = el.getOwnerDocument(); DOMImplementationLS domImplLS = (DOMImplementationLS) document .getImplementation(); LSSerializer serializer = domImplLS.createLSSerializer(); return serializer.writeToString(el); }
protected void printResponse() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementationLS ls = (DOMImplementationLS)docBuilder.getDOMImplementation(); LSSerializer lss = ls.createLSSerializer(); System.out.println(lss.writeToString(_docResponse)); } catch (ParserConfigurationException e) { s_logger.error("Error parsing the repsonse : " + e.toString()); } } }
LSSerializer lsSerializer = domImplementationLS.createLSSerializer(); String string = lsSerializer.writeToString(document); System.out.println(string);
public static String format(String xml) { try { final InputSource src = new InputSource(new StringReader(xml)); final Node document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(src).getDocumentElement(); final Boolean keepDeclaration = Boolean.valueOf(xml.startsWith("<?xml")); //May need this: System.setProperty(DOMImplementationRegistry.PROPERTY,"com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl"); final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS"); final LSSerializer writer = impl.createLSSerializer(); writer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE); // Set this to true if the output needs to be beautified. writer.getDomConfig().setParameter("xml-declaration", keepDeclaration); // Set this to true if the declaration is needed to be outputted. return writer.writeToString(document); } catch (Exception e) { throw new RuntimeException(e); } }
for (int i = 0; i < iMax; i++) { final Node item = bodies.item(i); sb.append(writer.writeToString(item)); for (int i = 0; i < iMax; i++) { final Node item = footnotes.item(i); sb.append(writer.writeToString(item));
pkg.appendChild(pe.node); sb.append(writer.writeToString(pkg));
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }
@Override public void serialize(Node value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_domImpl == null) throw new IllegalStateException("Could not find DOM LS"); LSSerializer writer = _domImpl.createLSSerializer(); jgen.writeString(writer.writeToString(value)); }