Code example for Element

Methods: setAttribute

0
 
            @Override 
            public void endElement(String uri, String localName, String qName) {
                addTextIfNeeded(); 
                Element closedEl = elementStack.pop();
                closedEl.setAttribute(lineEndNumAttribName, String.valueOf(locator.getLineNumber()));
                if (elementStack.isEmpty()) { // Is this the root element?
                    doc.appendChild(closedEl);
                } else { 
                    Element parentEl = elementStack.peek();
                    parentEl.appendChild(closedEl);
                } 
            } 
 
            @Override 
            public void characters(char ch[], int start, int length) throws SAXException {
                textBuffer.append(ch, start, length);
            } 
 
            // Outputs text accumulated under the current node 
            private void addTextIfNeeded() {