Hi, there. In my application I need to know when a DOM tree is changed. As there is a nice event model since DOM level 2, I tried to use that. But whatever I try, there are no events fired, although the tree gets changed. Can someone shed some light on this, or provide me a little example?
The code I wrote so far uses Xerces 1.4.1 and looks like this, and I expect it to throw an exception but it does not: public class DomEventDemo implements org.w3c.dom.events.EventListener { public DomEventDemo() { } public static void main(String[] args) throws Exception { org.w3c.dom.Document doc = chaudhuri.util.DOMUtil.parseString("<?xml version=\"1.0\"?><test attribut=\"1\"/>"); if(doc instanceof org.apache.xerces.dom.DocumentImpl) { ((org.apache.xerces.dom.DocumentImpl)doc).setMutationEvents(true); ((org.w3c.dom.events.EventTarget)doc).addEventListener("MutationEvents", new DomEventDemo(), false); } System.out.println("Vorher: "+chaudhuri.util.DOMUtil.toXML(doc)); org.w3c.dom.Node attr = org.apache.xpath.XPathAPI.selectSingleNode(doc, "/test/@attribut"); attr.setNodeValue("2"); System.out.println("Nachher: "+chaudhuri.util.DOMUtil.toXML(doc)); } public void handleEvent(org.w3c.dom.events.Event event) { throw new UnsupportedOperationException(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]