Package org.htmlparser

Examples of org.htmlparser.StringNode


    assertType("first child",AnotherTag.class,node);
    AnotherTag anotherTag = (AnotherTag)node;
    assertEquals("another tag children count",1,anotherTag.getChildCount());
    node = anotherTag.childAt(0);
    assertType("nested child",StringNode.class,node);
    StringNode text = (StringNode)node;
    assertEquals("text","Hello",text.toPlainTextString());
  }
View Full Code Here


    assertEquals("ending loc",7,customTag.getStartTag().elementEnd());
    assertEquals("starting line position",1,customTag.tagData.getStartLine());
    assertEquals("ending line position",1,customTag.tagData.getEndLine());
    AnotherTag anotherTag = (AnotherTag)customTag.childAt(0);
    assertEquals("anotherTag child count",1,anotherTag.getChildCount());
    StringNode stringNode = (StringNode)anotherTag.childAt(0);
    assertStringEquals("anotherTag child text","something",stringNode.toPlainTextString());
    assertStringEquals(
      "first custom tag html",
      "<CUSTOM><ANOTHER>something</ANOTHER></CUSTOM>",
      customTag.toHtml()
    );   
View Full Code Here

        Node[] nodes = nodeList.toNodeArray();

        assertEquals("Number of nodes found", 1, nodes.length);
        assertType("search result node", StringNode.class, nodes[0]);
        StringNode stringNode = (StringNode) nodes[0];
        assertEquals(
            "Expected contents of string node",
            "User Name",
            stringNode.getText());
    }
View Full Code Here

        // The first node should be a HTMLRemarkNode
        assertTrue(
            "First node should be a string node",
            node[0] instanceof StringNode);
        assertTrue("Second node should be a Tag", node[1] instanceof Tag);
        StringNode stringNode = (StringNode) node[0];
        Tag tag = (Tag) node[1];
        assertEquals("Text contents", "&nbsp;", stringNode.getText());
        assertEquals("Tag Contents", "![endif]", tag.getText());

    }
View Full Code Here

        StringBuffer buffer;
        PrintWriter out;
        boolean pass;
        NodeIterator enumeration;
        Node node;
        StringNode string;

        try
        {
            url =
                new URL("http://www.canadapost.ca/tools/pcl/bin/cp_search_response-e.asp");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty(
                "Referer",
                "http://www.canadapost.ca/tools/pcl/bin/default-e.asp");
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setUseCaches(false);
            buffer = new StringBuffer(1024);
            buffer.append("app_language=");
            buffer.append("english");
            buffer.append("&");
            buffer.append("app_response_start_row_number=");
            buffer.append("1");
            buffer.append("&");
            buffer.append("app_response_rows_max=");
            buffer.append("9");
            buffer.append("&");
            buffer.append("app_source=");
            buffer.append("quick");
            buffer.append("&");
            buffer.append("query_source=");
            buffer.append("q");
            buffer.append("&");
            buffer.append("name=");
            buffer.append("&");
            buffer.append("postal_code=");
            buffer.append("&");
            buffer.append("directory_area_name=");
            buffer.append("&");
            buffer.append("delivery_mode=");
            buffer.append("&");
            buffer.append("Suffix=");
            buffer.append("&");
            buffer.append("street_direction=");
            buffer.append("&");
            buffer.append("installation_type=");
            buffer.append("&");
            buffer.append("delivery_number=");
            buffer.append("&");
            buffer.append("installation_name=");
            buffer.append("&");
            buffer.append("unit_numbere=");
            buffer.append("&");
            buffer.append("app_state=");
            buffer.append("production");
            buffer.append("&");
            buffer.append("street_number=");
            buffer.append(number);
            buffer.append("&");
            buffer.append("street_name=");
            buffer.append(street);
            buffer.append("&");
            buffer.append("street_type=");
            buffer.append(type);
            buffer.append("&");
            buffer.append("test=");
            buffer.append("&");
            buffer.append("city=");
            buffer.append(city);
            buffer.append("&");
            buffer.append("prov=");
            buffer.append(province);
            buffer.append("&");
            buffer.append("Search=");
            out = new PrintWriter(connection.getOutputStream());
            out.print(buffer);
            out.close();
            parser = new Parser(connection);
        }
        catch (Exception e)
        {
            throw new ParserException(
                "You must be offline! This test needs you to be connected to the internet.",
                e);
        }

        pass = false;
        for (enumeration = parser.elements(); enumeration.hasMoreNodes();)
        {
            node = enumeration.nextNode();
            if (node instanceof StringNode)
            {
                string = (StringNode) node;
                if (-1 != string.getText().indexOf(postal_code))
                    pass = true;
            }
        }
        assertTrue("POST operation failed.", pass);
    }
View Full Code Here

                        node = reader.readElement();
                        if (node != null)
                        {
                            if (node instanceof StringNode)
                            {
                                StringNode stringNode = (StringNode) node;
                                if (xmlData.length() > 0)
                                    xmlData += " ";
                                xmlData += stringNode.getText();
                            }
                            else if (
                                !(node instanceof org.htmlparser.tags.EndTag))
                                xmlTagFound = false;
                        }
View Full Code Here

            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
View Full Code Here

        Node expectedNode,
        Node actualNode)
    {
        if (expectedNode instanceof StringNode)
        {
            StringNode expectedString = (StringNode) expectedNode;
            StringNode actualString = (StringNode) actualNode;
            assertStringEquals(
                displayMessage,
                expectedString.getText(),
                actualString.getText());
        }
    }
View Full Code Here

        parseAndAssertNodeCount(5);
        // The fourth node should be a HTMLStringNode-  with the text - Google
        assertTrue(
            "Fourth node should be a HTMLStringNode",
            node[3] instanceof StringNode);
        StringNode stringNode = (StringNode) node[3];
        assertEquals("Text of the StringNode", "Google", stringNode.getText());
    }
View Full Code Here

        parseAndAssertNodeCount(3);
        // The first node should be a HTMLStringNode-  with the text - view these documents, you must have
        assertTrue(
            "First node should be a HTMLStringNode",
            node[0] instanceof StringNode);
        StringNode stringNode = (StringNode) node[0];
        assertEquals(
            "Text of the StringNode",
            "view these documents, you must have ",
            stringNode.getText());
        assertTrue(
            "Second node should be a link node",
            node[1] instanceof LinkTag);
        LinkTag linkNode = (LinkTag) node[1];
        assertEquals("Link is", "http://www.adobe.com", linkNode.getLink());
        assertEquals(
            "Link text is",
            "Adobe \r\nAcrobat Reader",
            linkNode.getLinkText());

        assertTrue(
            "Third node should be a string node",
            node[2] instanceof StringNode);
        StringNode stringNode2 = (StringNode) node[2];
        assertEquals(
            "Contents of third node",
            " installed on your computer.",
            stringNode2.getText());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.StringNode

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.