/** * @see org.htmlparser.Tag#isEndTag() */ public boolean isEndTag() { return m_decorated.isEndTag(); }
/** * @see org.htmlparser.Tag#isEndTag() */ public boolean isEndTag() { return m_decorated.isEndTag(); }
/** * @see org.htmlparser.Tag#isEndTag() */ public boolean isEndTag() { return m_decorated.isEndTag(); }
/** * Accept nodes that are tags and have a matching tag name. * This discards non-tag nodes and end tags. * The end tags are available on the enclosing non-end tag. * @param node The node to check. * @return <code>true</code> if the tag name matches, * <code>false</code> otherwise. */ public boolean accept (Node node) { return ((node instanceof Tag) && !((Tag)node).isEndTag () && ((Tag)node).getTagName ().equals (mName)); } }
/** * Accept nodes that are tags and have a matching tag name. * This discards non-tag nodes and end tags. * The end tags are available on the enclosing non-end tag. * @param node The node to check. * @return <code>true</code> if the tag name matches, * <code>false</code> otherwise. */ public boolean accept (Node node) { return ((node instanceof Tag) && !((Tag)node).isEndTag () && ((Tag)node).getTagName ().equals (mName)); } }
if(!tag.isResource()) if(tag.isEndTag() && (tag.getParent() != null && tag.getParent().isResource()))
if (tag.isEndTag ()) ends = current.getEndTagEnders (); else
if (tag.isEndTag ()) ends = current.getEndTagEnders (); else
if (!tag.isEndTag ())
if (!tag.isEndTag ())
if (tag.isEndTag()) { replacementName = "/" + replacementName;
/** * Accept tags with parent acceptable to the filter. * If recursion is enabled, each parent in turn up to * the topmost enclosing node is checked. * Recursion only proceeds while no parent satisfies the * filter. * @param node The node to check. * @return <code>true</code> if the node has an acceptable parent, * <code>false</code> otherwise. */ public boolean accept (Node node) { Node parent; boolean ret; ret = false; if (!(node instanceof Tag) || !((Tag)node).isEndTag ()) { parent = node.getParent (); if ((null != parent) && (null != getParentFilter ())) { ret = getParentFilter ().accept (parent); if (!ret && getRecursive ()) ret = accept (parent); } } return (ret); } }
/** * Accept tags with parent acceptable to the filter. * If recursion is enabled, each parent in turn up to * the topmost enclosing node is checked. * Recursion only proceeds while no parent satisfies the * filter. * @param node The node to check. * @return <code>true</code> if the node has an acceptable parent, * <code>false</code> otherwise. */ public boolean accept (Node node) { Node parent; boolean ret; ret = false; if (!(node instanceof Tag) || !((Tag)node).isEndTag ()) { parent = node.getParent (); if ((null != parent) && (null != getParentFilter ())) { ret = getParentFilter ().accept (parent); if (!ret && getRecursive ()) ret = accept (parent); } } return (ret); } }
node = lexer.nextNode (false); if (null != node) if (!(node instanceof Tag) || !( ((Tag)node).isEndTag () && ((Tag)node).getTagName ().equals (tagname)))
if (!(node instanceof Tag) || !((Tag)node).isEndTag ())
if (!(node instanceof Tag) || !((Tag)node).isEndTag ())
node = lexer.nextNode (false); if (null != node) if (!(node instanceof Tag) || !( ((Tag)node).isEndTag () && ((Tag)node).getTagName ().equals (tag.getIds ()[0])))
node = lexer.nextNode (false); if (null != node) if (!(node instanceof Tag) || !( ((Tag)node).isEndTag () && ((Tag)node).getTagName ().equals (tag.getIds ()[0])))
/** * test expected behavior of htmlparser. * <p>htmlparser does neither unescape HTML entities found in text, nor * escape special characters in Node.toHtml(). We have a workaround based on this * behavior. If this expectation breaks, we need to modify our code.</p> * @throws Exception */ public void testHtmlParser_attributeValueEscaping() throws Exception { final String html = "<html>" + "<body>" + "<a href=\"http://example.com/api?a=1&b=2&c=3"\">anchor</a>" + "</body>" + "</html>"; byte[] bytes = html.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); Page page = new Page(bais, "UTF-8"); Lexer lexer = new Lexer(page); Node node; while ((node = lexer.nextNode()) != null) { if (node instanceof Tag) { Tag tag = (Tag)node; if (tag.getTagName().equalsIgnoreCase("A") && !tag.isEndTag()) { assertEquals("href", "http://example.com/api?a=1&b=2&c=3"", tag.getAttribute("HREF")); String htmlout = tag.toHtml(); assertEquals("toHtml output", "<a href=\"http://example.com/api?a=1&b=2&c=3"\">", htmlout); } } } }