I am trying to save the current position of the document on the stack by clicking on startElement, and exit on endElement. Now I am using:
public void startElement(String namespaceURI, String elname,
String qName, Attributes atts) throws SAXException {
original.append(innerText);
original.append("<");
original.append(elname);
original.append(">");
docStack.push(new StackElement(elname,atts));
....
Unfortunately, when he tries to read atts later, he gives an error: Called: java.lang.IllegalStateException: Attributes can only be used within the scope of startElement ().
Is there a quick and reliable way to store attributes? Also, is there a better way to do this than to create a new custom StackElement object for each start tag?
source
share