Package org.htmlparser

Examples of org.htmlparser.Tag


    public void testTagWithOpenTagSymbolInAttribute() throws ParserException {
        createParser("<tag att=\"a<b\">");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("attribute","a<b",tag.getAttribute("att"));
    }
View Full Code Here


        String html = "<tag att=\'a<b\'>";
        createParser(html);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("html",html,tag.toHtml());
        assertStringEquals("attribute","a<b",tag.getAttribute("att"));
    }
View Full Code Here

        createParser("<HTML></HTML>");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(2);
        // The node should be a tag
        assertTrue("Node should be a Tag",node[1] instanceof Tag);
        Tag endTag = (Tag)node[1];
        assertTrue("Node should be an end Tag",endTag.isEndTag ());
        assertEquals("Raw String","</HTML>",endTag.toHtml());
    }
View Full Code Here

        createParser(testHtml);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        int pos = testHtml.indexOf("</SCRIPT>");
        parseAndAssertNodeCount(4);
        assertTrue("Node should be a Tag",node[2] instanceof Tag);
        Tag endTag = (Tag)node[2];
        assertTrue("Node should be an end Tag",endTag.isEndTag ());
        assertEquals("endtag element begin",pos,endTag.getStartPosition ());
        assertEquals("endtag element end",pos+9,endTag.getEndPosition ());
    }
View Full Code Here

      if (mValue == null) {
        return false;
      }

      Tag tag = (Tag) node;
      if (tag.getAttributeEx(mAttribute) == null) {
        return false;
      }

      return tag.getAttributeEx(mAttribute).getValue().startsWith(mValue);
    }
View Full Code Here

      row.setExecutionResult(exceptionResult.getExecutionResult());
    }
  }

  private static Tag newTag(Class<? extends Tag> klass) {
    Tag tag = null;
    try {
      tag = klass.newInstance();
      tag.setTagName(tag.getTagName().toLowerCase());
      Tag endTag = klass.newInstance();
      endTag.setTagName("/" + tag.getTagName().toLowerCase());
      endTag.setParent(tag);
      tag.setEndTag(endTag);
    } catch (Exception e) {
      LOG.log(Level.WARNING, "Unable to create tag from class " + klass, e);
    }
    return tag;
View Full Code Here

    }

    public Row() {
      rowNode = (TableRow) newTag(TableRow.class);
      rowNode.setChildren(new NodeList());
      Tag endNode = new TableRow();
      endNode.setTagName("/" + rowNode.getTagName().toLowerCase());
      rowNode.setEndTag(endNode);
    }
View Full Code Here

    private void setExecutionResult(ExecutionResult executionResult) {
      NodeList cells = rowNode.getChildren();
      for (int i = 0; i < cells.size(); i++) {
        Node cell = cells.elementAt(i);
        if (cell instanceof Tag) {
          Tag tag = (Tag) cell;
          tag.setAttribute("class", executionResult.toString(), '"');
        }
      }
    }
View Full Code Here

    } catch (CloneNotSupportedException e) {
      throw new RuntimeException("Node must be cloneable", e);
    }
    node.setParent(clonedParent);
    if (newNode instanceof Tag) {
      Tag newTag = (Tag) newNode;
      newTag.setAttributesEx(cloneAttributes(((Tag) node).getAttributesEx()));
    }
    return newNode;
  }
View Full Code Here

            Node node = lexer.nextNode();
            while (node != null && doContinue)
            {
                if (node instanceof Tag)
                {
                    Tag tag = (Tag) node;
                    String tagName = tag.getTagName();

                    if ("TABLE".equals(tagName)) //$NON-NLS-1$
                        doContinue = table(tag);
                    else if ("TBODY".equals(tagName)) //$NON-NLS-1$
                        doContinue = tbody(tag);
View Full Code Here

TOP

Related Classes of org.htmlparser.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.