Code example for Node

Methods: getChildNodes, hasAttributes

0
 
    public void testNestedText() { 
        XMLFragment x = (XMLFragment) getProject().getReference("nested-text");
        assertNotNull(x);
        Node n = x.getFragment();
        assertTrue("No attributes", !n.hasAttributes());
        NodeList nl = n.getChildNodes();
        assertEquals(1, nl.getLength());
        assertEquals(Node.TEXT_NODE, nl.item(0).getNodeType());
        assertEquals("foo", nl.item(0).getNodeValue());
    } 
 
    public void testNestedChildren() { 
        XMLFragment x =
            (XMLFragment) getProject().getReference("with-children"); 
        assertNotNull(x);
        Node n = x.getFragment();
        assertTrue("No attributes", !n.hasAttributes());
        NodeList nl = n.getChildNodes();
        assertEquals(3, nl.getLength());