@Override public String toString() { if (toString == null) { StringBuilder sb = new StringBuilder(); sb.append('<').append(element.getTagName()); NamedNodeMap attributes = element.getAttributes(); int n = attributes.getLength(); for (int i = 0; i < n; ++i) { Attr a = (Attr) attributes.item(i); sb.append(' ').append(a.getName()).append("=\"") .append(a.getValue().replace("\"", """)).append("\""); } if (element.hasChildNodes()) { sb.append('>'); } else { sb.append(" />"); } toString = sb.toString(); } return toString; }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param printWriter the writer to print in */ protected void printOpeningTagContentAsXml(final PrintWriter printWriter) { printWriter.print(getTagName()); for (final Map.Entry<String, DomAttr> entry : attributes_.entrySet()) { printWriter.print(" "); printWriter.print(entry.getKey()); printWriter.print("=\""); printWriter.print(StringUtils.escapeXmlAttributeValue(entry.getValue().getNodeValue())); printWriter.print("\""); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param node the node whose opening tag is to be printed * @throws IOException in case of problem saving resources */ protected void printOpeningTag(final DomElement node) throws IOException { builder_.append(node.getTagName()); final Map<String, DomAttr> attributes = readAttributes(node); for (final Map.Entry<String, DomAttr> entry : attributes.entrySet()) { builder_.append(" "); builder_.append(entry.getKey()); builder_.append("=\""); final String value = entry.getValue().getNodeValue(); builder_.append(com.gargoylesoftware.htmlunit.util.StringUtils.escapeXmlAttributeValue(value)); builder_.append('"'); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param printWriter the writer to print in */ protected void printOpeningTagContentAsXml(final PrintWriter printWriter) { printWriter.print(getTagName()); for (final Map.Entry<String, DomAttr> entry : attributes_.entrySet()) { printWriter.print(" "); printWriter.print(entry.getKey()); printWriter.print("=\""); printWriter.print(StringUtils.escapeXmlAttributeValue(entry.getValue().getNodeValue())); printWriter.print("\""); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param node the node whose opening tag is to be printed * @throws IOException in case of problem saving resources */ protected void printOpeningTag(final DomElement node) throws IOException { builder_.append(node.getTagName()); final Map<String, DomAttr> attributes = readAttributes(node); for (final Map.Entry<String, DomAttr> entry : attributes.entrySet()) { builder_.append(' '); builder_.append(entry.getKey()); builder_.append("=\""); final String value = entry.getValue().getNodeValue(); builder_.append(com.gargoylesoftware.htmlunit.util.StringUtils.escapeXmlAttributeValue(value)); builder_.append('"'); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param printWriter the writer to print in */ protected void printOpeningTagContentAsXml(final PrintWriter printWriter) { printWriter.print(getTagName()); for (final String name : attributes_.keySet()) { printWriter.print(" "); printWriter.print(name); printWriter.print("=\""); printWriter.print(StringEscapeUtils.escapeXml(attributes_.get(name).getNodeValue())); printWriter.print("\""); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param printWriter the writer to print in */ protected void printOpeningTagContentAsXml(final PrintWriter printWriter) { printWriter.print(getTagName()); for (final String name : attributes_.keySet()) { printWriter.print(" "); printWriter.print(name); printWriter.print("=\""); printWriter.print(StringEscapeUtils.escapeXml(attributes_.get(name).getNodeValue())); printWriter.print("\""); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param printWriter the writer to print in */ protected void printOpeningTagContentAsXml(final PrintWriter printWriter) { printWriter.print(getTagName()); for (final String name : attributes_.keySet()) { printWriter.print(" "); printWriter.print(name); printWriter.print("=\""); printWriter.print(StringEscapeUtils.escapeXml(attributes_.get(name).getNodeValue())); printWriter.print("\""); } }
@Override public boolean isSelected() { assertElementNotStale(); if (element instanceof HtmlInput) { return ((HtmlInput) element).isChecked(); } else if (element instanceof HtmlOption) { return ((HtmlOption) element).isSelected(); } throw new UnsupportedOperationException( "Unable to determine if element is selected. Tag name is: " + element.getTagName()); }
protected void printXml(final DomElement node) throws IOException { if (!isExcluded(node)) { final boolean hasChildren = node.getFirstChild() != null; builder_.append(indent_).append('<'); printOpeningTag(node); if (!hasChildren && !node.isEmptyXmlTagExpanded()) { builder_.append("/>").append('\n'); } else { builder_.append(">").append('\n'); for (DomNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) { indent_.append(" "); if (child instanceof DomElement) { printXml((DomElement) child); } else { builder_.append(child); } indent_.setLength(indent_.length() - 2); } builder_.append(indent_).append("</").append(node.getTagName()).append('>').append('\n'); } } }
/** * Recursively write the XML data for the node tree starting at <code>node</code>. * * @param indent white space to indent child nodes * @param printWriter writer where child nodes are written */ @Override protected void printXml(final String indent, final PrintWriter printWriter) { final boolean hasChildren = getFirstChild() != null; printWriter.print(indent + "<"); printOpeningTagContentAsXml(printWriter); if (hasChildren || isEmptyXmlTagExpanded()) { printWriter.print(">\r\n"); printChildrenAsXml(indent, printWriter); printWriter.print(indent); printWriter.print("</"); printWriter.print(getTagName()); printWriter.print(">\r\n"); } else { printWriter.print("/>\r\n"); } }
protected void printXml(final DomElement node) { if (!isExcluded(node)) { final boolean hasChildren = node.getFirstChild() != null; buffer_.append(indent_).append('<'); printOpeningTag(node); if (!hasChildren && !isEmptyXmlTagExpanded(node)) { buffer_.append("/>").append('\n'); } else { buffer_.append(">").append('\n'); for (DomNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) { indent_.append(" "); if (child instanceof DomElement) { printXml((DomElement) child); } else { buffer_.append(child); } indent_.setLength(indent_.length() - 2); } buffer_.append(indent_).append("</").append(node.getTagName()).append('>').append('\n'); } } }
protected void printXml(final DomElement node) { if (!isExcluded(node)) { final boolean hasChildren = node.getFirstChild() != null; buffer_.append(indent_).append('<'); printOpeningTag(node); if (!hasChildren && !isEmptyXmlTagExpanded(node)) { buffer_.append("/>").append('\n'); } else { buffer_.append(">").append('\n'); for (DomNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) { indent_.append(" "); if (child instanceof DomElement) { printXml((DomElement) child); } else { buffer_.append(child); } indent_.setLength(indent_.length() - 2); } buffer_.append(indent_).append("</").append(node.getTagName()).append('>').append('\n'); } } }
/** * Recursively write the XML data for the node tree starting at <code>node</code>. * * @param indent white space to indent child nodes * @param printWriter writer where child nodes are written */ @Override protected void printXml(final String indent, final PrintWriter printWriter) { final boolean hasChildren = getFirstChild() != null; printWriter.print(indent + "<"); printOpeningTagContentAsXml(printWriter); if (hasChildren || isEmptyXmlTagExpanded()) { printWriter.print(">\r\n"); printChildrenAsXml(indent, printWriter); printWriter.print(indent); printWriter.print("</"); printWriter.print(getTagName()); printWriter.print(">\r\n"); } else { printWriter.print("/>\r\n"); } }
protected void printXml(final DomElement node) { if (!isExcluded(node)) { final boolean hasChildren = node.getFirstChild() != null; buffer_.append(indent_).append('<'); printOpeningTag(node); if (!hasChildren && !isEmptyXmlTagExpanded(node)) { buffer_.append("/>").append('\n'); } else { buffer_.append(">").append('\n'); for (DomNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) { indent_.append(" "); if (child instanceof DomElement) { printXml((DomElement) child); } else { buffer_.append(child); } indent_.setLength(indent_.length() - 2); } buffer_.append(indent_).append("</").append(node.getTagName()).append('>').append('\n'); } } }
protected void printXml(final DomElement node) throws IOException { if (!isExcluded(node)) { final boolean hasChildren = node.getFirstChild() != null; builder_.append(indent_).append('<'); printOpeningTag(node); if (!hasChildren && !node.isEmptyXmlTagExpanded()) { builder_.append("/>").append('\n'); } else { builder_.append('>').append('\n'); for (DomNode child = node.getFirstChild(); child != null; child = child.getNextSibling()) { indent_.append(" "); if (child instanceof DomElement) { printXml((DomElement) child); } else { builder_.append(child); } indent_.setLength(indent_.length() - 2); } builder_.append(indent_).append("</").append(node.getTagName()).append('>').append('\n'); } } }
/** * Recursively write the XML data for the node tree starting at <code>node</code>. * * @param indent white space to indent child nodes * @param printWriter writer where child nodes are written */ @Override protected void printXml(final String indent, final PrintWriter printWriter) { final boolean hasChildren = (getFirstChild() != null); printWriter.print(indent + "<"); printOpeningTagContentAsXml(printWriter); if (!hasChildren && !isEmptyXmlTagExpanded()) { printWriter.println("/>"); } else { printWriter.println(">"); printChildrenAsXml(indent, printWriter); printWriter.println(indent + "</" + getTagName() + ">"); } }
/** * Recursively write the XML data for the node tree starting at <code>node</code>. * * @param indent white space to indent child nodes * @param printWriter writer where child nodes are written */ @Override protected void printXml(final String indent, final PrintWriter printWriter) { final boolean hasChildren = (getFirstChild() != null); printWriter.print(indent + "<"); printOpeningTagContentAsXml(printWriter); if (!hasChildren && !isEmptyXmlTagExpanded()) { printWriter.println("/>"); } else { printWriter.println(">"); printChildrenAsXml(indent, printWriter); printWriter.println(indent + "</" + getTagName() + ">"); } }
/** * Recursively write the XML data for the node tree starting at <code>node</code>. * * @param indent white space to indent child nodes * @param printWriter writer where child nodes are written */ @Override protected void printXml(final String indent, final PrintWriter printWriter) { final boolean hasChildren = (getFirstChild() != null); printWriter.print(indent + "<"); printOpeningTagContentAsXml(printWriter); if (!hasChildren && !isEmptyXmlTagExpanded()) { printWriter.println("/>"); } else { printWriter.println(">"); printChildrenAsXml(indent, printWriter); printWriter.println(indent + "</" + getTagName() + ">"); } }
/** * Prints the content between "<" and ">" (or "/>") in the output of the tag name * and its attributes in XML format. * @param node the node whose opening tag is to be printed */ protected void printOpeningTag(final DomElement node) { buffer_.append(node.getTagName()); final Map<String, DomAttr> attributes; if (node instanceof HtmlScript) { attributes = getAttributesFor((HtmlScript) node); } else if (node instanceof HtmlImage) { attributes = getAttributesFor((HtmlImage) node); } else if (node instanceof HtmlLink) { attributes = getAttributesFor((HtmlLink) node); } else { attributes = node.getAttributesMap(); } for (final String name : attributes.keySet()) { buffer_.append(" "); buffer_.append(name); buffer_.append("=\""); buffer_.append(StringEscapeUtils.escapeXml(attributes.get(name).getNodeValue())); buffer_.append("\""); } }