Package org.htmlparser

Examples of org.htmlparser.Node


        if (tagContents.length() == 0)
            return this;
        try
        {
            boolean found = false;
            Node retVal = null;
            // Find the first word in the scanners
            String firstWord = extractWord(tagContents.toString());
            // Now, get the scanner associated with this.
            TagScanner scanner = (TagScanner) scanners.get(firstWord);
View Full Code Here


    private void adjustVectorCapacity()
    {
        capacity += capacityIncrement;
        capacityIncrement *= 2;
        Node oldData[] = nodeData;
        nodeData = new Node[capacity];
        System.arraycopy(oldData, 0, nodeData, 0, size);
        numberOfAdjustments++;
    }
View Full Code Here

    }

    public NodeList searchFor(Class classType)
    {
        NodeList foundList = new NodeList();
        Node node;
        for (int i = 0; i < size; i++)
        {
            if (nodeData[i].getClass().getName().equals(classType.getName()))
                foundList.add(nodeData[i]);
        }
View Full Code Here

    /**
     * Pull out text elements from the HTML.
     */
    public void parse() throws ParserException
    {
        Node node;
        StringBuffer buffer = new StringBuffer(4096);

        // Run through an enumeration of html elements, and pick up
        // only those that are plain string.
        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            node = e.nextNode();

            if (node instanceof StringNode)
            {
                // Node is a plain string
                // Cast it to an HTMLStringNode
                StringNode stringNode = (StringNode) node;
                // Retrieve the data from the object
                buffer.append(stringNode.getText());
            }
            else if (node instanceof LinkTag)
            {
                // Node is a link
                // Cast it to an HTMLLinkTag
                LinkTag linkNode = (LinkTag) node;
                // Retrieve the data from the object and print it
                buffer.append(linkNode.getLinkText());
            }
            else if (node instanceof Tag)
            {
                String contents = ((Tag) node).getText();
                if (contents.equals("BR") || contents.equals("P"))
                    buffer.append(nl);
            }
            else if (node instanceof EndTag)
            {
                String contents = ((EndTag) node).getText();
                if (contents.equals("BR") || contents.equals("P"))
                    buffer.append(nl);
            }
            else if (node instanceof RemarkNode)
            {
            }
            else
            {
                System.out.println();
                System.out.println(node.toString());
            }
        }

        String text = translate(buffer.toString());
        sgml(text);
View Full Code Here

     */
    public static Node[] findTypeInNode(Node node, Class type)
    {
        NodeList nodeList = new NodeList();
        node.collectInto(nodeList, type);
        Node spans[] = nodeList.toNodeArray();
        return spans;
    }
View Full Code Here

        sb.append(startTag.toHtml());
    }

    protected void putChildrenInto(StringBuffer sb)
    {
        Node node, prevNode = startTag;
        for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            if (prevNode != null)
            {
                if (prevNode.elementEnd() > node.elementBegin())
                {
                    // Its a new line
                    sb.append(lineSeparator);
                }
            }
            sb.append(node.toHtml());
            prevNode = node;
        }
        if (prevNode.elementEnd() > endTag.elementBegin())
        {
            sb.append(lineSeparator);
View Full Code Here

     * @param name Attribute to match in tag
     * @return Tag Tag matching the name attribute
     */
    public Tag searchByName(String name)
    {
        Node node;
        Tag tag = null;
        boolean found = false;
        for (SimpleNodeIterator e = children(); e.hasMoreNodes() && !found;)
        {
            node = (Node) e.nextNode();
View Full Code Here

     */

    public NodeList searchFor(String searchString, boolean caseSensitive)
    {
        NodeList foundList = new NodeList();
        Node node;
        if (!caseSensitive)
            searchString = searchString.toUpperCase();
        for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            String nodeTextString = node.toPlainTextString();
            if (!caseSensitive)
                nodeTextString = nodeTextString.toUpperCase();
            if (nodeTextString.indexOf(searchString) != -1)
            {
                foundList.add(node);
View Full Code Here

     * @param text
     * @return int
     */
    public int findPositionOf(String text)
    {
        Node node;
        int loc = 0;
        for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            if (node
                .toPlainTextString()
                .toUpperCase()
                .indexOf(text.toUpperCase())
                != -1)
            {
View Full Code Here

     * @param text
     * @return int
     */
    public int findPositionOf(Node searchNode)
    {
        Node node;
        int loc = 0;
        for (SimpleNodeIterator e = children(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            if (node == searchNode)
View Full Code Here

TOP

Related Classes of org.htmlparser.Node

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.