Code example for Element

Methods: getTagName

0
        Document doc = XMLUtils.newDocument(inputsrc);
 
        NodeList nl = doc.getElementsByTagName("display-name");
        Element elem = (Element)nl.item(0);
        String expected = "<display-name>Apache-Axis</display-name>";
        String result = XMLUtils.ElementToString(elem);
        assertEquals("Element tag name is not 'display-name', it is: " + elem.getTagName(),
                     "display-name", elem.getTagName());
        assertEquals("Did not get the expected result", expected, result);
    } 
 
    public void testGetInnerXMLString() throws Exception 
    { 
        Reader reader = (Reader)this.getTestXml("reader");
        InputSource inputsrc = new InputSource(reader);
        Document doc = XMLUtils.newDocument(inputsrc);
 
        NodeList nl = doc.getElementsByTagName("display-name");
        Element elem = (Element)nl.item(0);
        String expected = "Apache-Axis";
        String result = XMLUtils.getInnerXMLString(elem);