I have a WebView which is initialized with the following content:
<!DOCTYPE html><html>
<body>
<div class="section" id="header"></div>
<div class="section" id="content"></div>
<div class="section" id="status"></div>
</body>
</html>
I then get a reference to the "header" node, and attempt o set some HMTL to it:
org.w3c.dom.Document doc = webView.getEngine().getDocument();
Node headerNode = doc.getElementById("header");
headerNode.setNodeValue("<b>abc</b><i>defg</i>");
I don't, however, see any changes to the output in the webview. I then tried to read back the HTML from the webview, to check whether my update took place:
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
System.out.println(writer.toString());
To my surprise, this was printed out:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><HTML xmlns="http://www.w3.org/1999/xhtml"><BODY><DIV class="section" id="header"/><DIV class="section" id="content"/><DIV class="section" id="status"/></BODY></HTML>
Not sure why the doctype was changed, and why my update did not take effect. My question is:
How can I append that small HTML fragment to the DIV node I got a reference to?
Thanks!