Package org.htmlparser.nodes

Examples of org.htmlparser.nodes.TagNode


        assertTrue ("should not be standalone", !attribute.isStandAlone ());
        assertTrue ("should not be whitespace", !attribute.isWhitespace ());
        assertTrue ("should be valued", attribute.isValued ());
        assertTrue ("should not be empty", !attribute.isEmpty ());
         attributes.add (attribute);
        tag = new TagNode (null, 0, 0, attributes);
        html = "<wombat label=\"The civil war.\" frameborder= no name=\"topFrame\">";
        assertStringEquals ("tag contents", html, tag.toHtml ());
    }
View Full Code Here


      Node node;

      node = lexer.nextNode();
      // HTMLParser returns CDATA section as TagNode
      assertTrue(node instanceof TagNode);
      TagNode tag = (TagNode)node;
      // whose tagName is "![CDATA[" *plus* non-whitespace chars following
      // it.  And if they are alphabets, they get capitalized.
      assertTrue(tag.getTagName().startsWith("![CDATA["));
      assertEquals("AAAA", tag.getTagName().substring("![CDATA[".length()));
      // Fortunately, getText() returns entire CDATA section, including
      // leading "!CDATA[" and trailing "]]" (no < and >), unmodified.
      String text = tag.getText();
      System.out.println("text=\"" + text + "\" (" + text.length() + " chars)");
      assertEquals("![CDATA[aaaa\nbbbb]]", text);
      // but setText() results in ClassCastException
      try {
        tag.setText("![CDATA[bbbb]]");
        fail("setText() did not throw an Exception");
      } catch (ClassCastException ex) {
        // expected
      }
    }
View Full Code Here

        handleJSTextNode(context, textNode);
      }
      emit(context, null, textNode, null);
//        handleContentTextNode(context,textNode);
    } else if (NodeUtils.isTagNode(node)) {
      TagNode tagNode = (TagNode)node;

      if (tagNode.isEndTag()) {
        if (tagNode.getTagName().equals("HEAD")) {
          context.putData(FERRET_IN_HEAD, null);
        }

        if (checkAllowTag(pContext, tagNode)) {
          emit(context, null, tagNode, null);
        }

//        handleCloseTagNode(context,tagNode);
      } else if (tagNode.getTagName().startsWith("![CDATA[")) {
        // CDATA section is delivered as TagNode, and it
        // appears there's no ordinary way of replacing its
        // body content. Also CSS/JS handling method wants
        // TextNode. Create a temporary TextNode for them,
        // and write "<![CDATA["..."]]>" around it.
        String text = tagNode.getText();
        int s = "![CDATA[".length();
        // text is supposed to end with "]]", but just in case.
        int e = text.endsWith("]]") ? text.length() - 2 : text.length();
        if (context.isInCSS()) {
          TextNode textNode = new TextNode(text.substring(s, e));
View Full Code Here

        handleJSTextNode(context,textNode);
      } else {
        handleContentTextNode(context,textNode);
      }
    } else if(NodeUtils.isTagNode(node)) {
      TagNode tagNode = (TagNode) node;
      if(tagNode.isEndTag()) {
        handleCloseTagNode(context,tagNode);
      } else {
        // assume start, possibly empty:
        handleOpenTagNode(context,tagNode);
      }
View Full Code Here

  public static boolean isRemarkNode(Node node) {
    return (node instanceof RemarkNode);
  }
  public static boolean isTagNodeNamed(Node node, String name) {
    if(isTagNode(node)) {
      TagNode tagNode = (TagNode) node;
      String nodeName = tagNode.getTagName();
      return nodeName.equals(name);
    }
    return false;
  }
View Full Code Here

    }
    return false;
  }
  public static boolean isOpenTagNodeNamed(Node node, String name) {
    if(isTagNode(node)) {
      TagNode tagNode = (TagNode) node;
      if(!tagNode.isEndTag()) {
        String nodeName = tagNode.getTagName();
        return nodeName.equals(name);
      }
    }
    return false;
  }
View Full Code Here

    }
    return false;
  }
  public static boolean isNonEmptyOpenTagNodeNamed(Node node, String name) {
    if(isTagNode(node)) {
      TagNode tagNode = (TagNode) node;
      if(!tagNode.isEndTag() && !tagNode.isEmptyXmlTag()) {
        String nodeName = tagNode.getTagName();
        return nodeName.equals(name);
      }
    }
    return false;
  }
View Full Code Here

    }
    return false;
  }
  public static boolean isCloseTagNodeNamed(Node node, String name) {
    if(isTagNode(node)) {
      TagNode tagNode = (TagNode) node;
      if(tagNode.isEndTag()) {
        String nodeName = tagNode.getTagName();
        return nodeName.equals(name);
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.nodes.TagNode

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.