/** * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, * java.lang.String) */ @Override public void endElement(String uri, String localName, String qName) throws SAXException { XmlNode node = this.stack.pop(); XmlNode parent = this.stack.size() > 0 ? this.stack.peek() : null; if (parent != null) { parent.addChild(node); } }
/** * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { XmlNode xmlNode = this.stack.size() == 0 ? this : new XmlNode(); xmlNode.name = localName; xmlNode.type = ELEMENT_NODE; xmlNode.valid = true; if (attributes != null) { for (int attributeIndex = 0; attributeIndex < attributes.getLength(); ++attributeIndex) { xmlNode.addAttribute( attributes.getLocalName(attributeIndex), attributes.getValue(attributeIndex)); } } this.stack.push(xmlNode); }