Code example for Element

Methods: getAttribute, getAttributeNode

0
        writer.close();
 
        Document document = parser.parse(new FileInputStream(file));
        assertNotNull(document);
        Element root = document.getDocumentElement();
        assertEquals(file.getPath(), value, root.getAttribute("attr"));
        assertEquals(4, parser.getPosition(root).getLine());
 
        Attr attribute = root.getAttributeNode("attr");
        assertNotNull(attribute);
        Position position = parser.getPosition(attribute);
        assertNotNull(position);
        assertEquals(4, position.getLine());
        assertEquals(startAttrOffset, position.getOffset());
 
        file.delete();
    } 
 
    public void testEncoding() throws Exception { 
        checkEncoding("utf-8", false /*bom*/, true /*encoding*/, "\n"); 
        checkEncoding("UTF-8", false /*bom*/, true /*encoding*/, "\n");