I want to use JavaFX WebView as XML viewer. I want to manage the XML Documents and not have to load each through the WebView as string, but use pre-loaded XML (DOM) Documents.
So basically doing the equivalent to the missing functionality webEngine.setDocument(doc). I want to control the DOM Document so I can dynamically make changes, attach events etc, which works fine, but is all lost on reloading the XML with webEngine.loadContent(String) and getDocument().
If this is really not possible, alternatively as work around, I can load a blank XML using:
webEngine.loadContent("", "text/xml");
then use getDocument() to get the top node. This works ok so far and (after completion) I obtain an empty but apparently valid XML Document. How can I add a child to this, specifically assign the top element from my existing Document? I've tried things like:
webEngine.getDocumentElement().appendChild(newdoc.getDocumentElement());
or
webEngine.getDocumentElement().appendChild(newdoc.getDocumentElement().getFirstChild());
where newdoc is one of my existing DOM Documents. This and other variations always result in ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl cannot be cast to com.sun.webkit.dom.NodeImpl
Thank you, I appreciate any help!