public HtmlSerializer get() { return new DefaultHtmlSerializer(); } }
public void serialize(Node n, Appendable output) throws IOException { serialize(n, output, false); }
@Override protected void writeComment(Node n, Appendable output) throws IOException { if (isSpecialTag(n.getParentNode().getNodeName())) { super.writeComment(n, output); } else if (isIeConditionalComment(n)) { super.writeComment(n, output); } }
/** {@inheritDoc} */ public String serialize(Document doc) { try { StringWriter sw = HtmlSerialization.createWriter(doc); if (doc.getDoctype() != null) { outputDocType(doc.getDoctype(), sw); } this.serialize(doc, sw); return sw.toString(); } catch (IOException ioe) { return null; } }
private String serialize(Node node) throws IOException { StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); new DefaultHtmlSerializer().serialize(child, sb); } return sb.toString(); }
writeComment(n, output); break; NodeList children = ((Document)n).getChildNodes(); for (int i = 0; i < children.getLength(); i++) { serialize(children.item(i), output, xmlMode); Element elem = (Element) n; NodeList children = elem.getChildNodes(); elem = substituteElement(elem); printStartElement(elem, output, xmlMode && htmlElement.isEmpty()); serialize(children.item(i), output, childXmlMode); writeText(n, output); break;
@Override protected void writeText(Node n, Appendable output) throws IOException { if (isSpecialTag(n.getParentNode().getNodeName())) { super.writeText(n, output); } else { collapseWhitespace(n.getTextContent(), output); } }
/** * Print the start of an HTML element. If withXmlClose==true, this is an * empty element that should have its content */ private static void printStartElement(Element elem, Appendable output, boolean withXmlClose) throws IOException { output.append("<").append(elem.getTagName()); NamedNodeMap attributes = elem.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Attr attr = (Attr)attributes.item(i); String attrName = attr.getNodeName(); output.append(' ').append(attrName); if (attr.getNodeValue() != null) { output.append("=\""); if (attr.getNodeValue().length() != 0) { printAttributeValue(attr.getNodeValue(), output); } output.append('"'); } } output.append(withXmlClose ? "/>" : ">"); }
private String serialize(Node node) throws IOException { StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); new DefaultHtmlSerializer().serialize(child, sb); } return sb.toString(); }
writeComment(n, output); break; NodeList children = ((Document)n).getChildNodes(); for (int i = 0; i < children.getLength(); i++) { serialize(children.item(i), output, xmlMode); Element elem = (Element) n; NodeList children = elem.getChildNodes(); elem = substituteElement(elem); printStartElement(elem, output, xmlMode && htmlElement.isEmpty()); serialize(children.item(i), output, childXmlMode); writeText(n, output); break;
/** {@inheritDoc} */ public String serialize(Document doc) { try { StringWriter sw = HtmlSerialization.createWriter(doc); if (doc.getDoctype() != null) { outputDocType(doc.getDoctype(), sw); } this.serialize(doc, sw); return sw.toString(); } catch (IOException ioe) { return null; } }
@Override protected void writeText(Node n, Appendable output) throws IOException { if (isSpecialTag(n.getParentNode().getNodeName())) { super.writeText(n, output); } else { collapseWhitespace(n.getTextContent(), output); } }
/** * Print the start of an HTML element. If withXmlClose==true, this is an * empty element that should have its content */ private static void printStartElement(Element elem, Appendable output, boolean withXmlClose) throws IOException { output.append("<").append(elem.getTagName()); NamedNodeMap attributes = elem.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Attr attr = (Attr)attributes.item(i); String attrName = attr.getNodeName(); output.append(' ').append(attrName); if (attr.getNodeValue() != null) { output.append("=\""); if (attr.getNodeValue().length() != 0) { boolean isUrlAttribute = elem.getNamespaceURI() == null && HtmlSerialization.URL_ATTRIBUTES.contains(attrName); printAttributeValue(attr.getNodeValue(), output, isUrlAttribute); } output.append('"'); } } output.append(withXmlClose ? "/>" : ">"); }
private String serialize(Node node) throws IOException { StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); new DefaultHtmlSerializer().serialize(child, sb); } return sb.toString(); }
writeComment(n, output); break; NodeList children = n.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { serialize(children.item(i), output, xmlMode); Element elem = (Element) n; NodeList children = elem.getChildNodes(); elem = substituteElement(elem); serialize(children.item(i), output, childXmlMode); writeText(n, output); break;
public HtmlSerializer get() { return new DefaultHtmlSerializer(); } }
public void serialize(Node n, Appendable output) throws IOException { serialize(n, output, false); }
@Override protected void writeComment(Node n, Appendable output) throws IOException { if (isSpecialTag(n.getParentNode().getNodeName())) { super.writeComment(n, output); } else if (isIeConditionalComment(n)) { super.writeComment(n, output); } }
@Override protected void writeText(Node n, Appendable output) throws IOException { if (isSpecialTag(n.getParentNode().getNodeName())) { super.writeText(n, output); } else { collapseWhitespace(n.getTextContent(), output); } }
private String serialize(Node node) throws IOException { StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); new DefaultHtmlSerializer().serialize(child, sb); } return sb.toString(); } }