Code example for Element

Methods: getAttributeshasAttributes

0
 
    protected void runTest() throws Throwable { 
        Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(
                "<root><child xmlns=\"\"/></root>"))); 
        Element element = (Element)doc.getDocumentElement().getFirstChild();
        assertTrue(element.hasAttributes());
        NamedNodeMap attributes = element.getAttributes();
        assertEquals(1, attributes.getLength());
        Attr attr = (Attr)attributes.item(0);
        assertEquals("xmlns", attr.getName());
        assertNull(attr.getPrefix());
        assertEquals("xmlns", attr.getLocalName());
        assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr.getNamespaceURI());
        assertEquals("", attr.getValue());
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java