Code example for NodeList

Methods: getLength, item

0
        Element newElement;
        String prefix;
        String lname;
        doc = (Document) load("staffNS", builder);
        newList = doc.getElementsByTagNameNS("*", "employee");
        assertEquals("employeeCount", 5, newList.getLength());
        newElement = (Element) newList.item(3);
        prefix = newElement.getPrefix();
        assertEquals("prefix", "emp", prefix);
        lname = newElement.getLocalName();
        assertEquals("lname", "employee", lname);
    } 
    public void testGetElementsByTagNameNS3() throws Throwable { 
        Document doc;
        NodeList elementList;
        Node child;
        String childName;
        List<String> result = new ArrayList<String>();
 
        List<String> expectedResult = new ArrayList<String>();
        expectedResult.add("employee");