Hi,
I've been running into problem after problem trying to use the a third party HTML editor to do what (I hoped) was a simple operation. Because of these problems, I'm looking for recommendations for an alternative HTML parser I could use to perform the operations.
Here's my situation, I have span tags in my html (with an ID attribute to identify them) and I simply want to replace their contents based on an update in another area of my client. For example:
<html>
<body>
<p>Hello <span id="1">name</span> you are <span id="2">age</span></p>
</body>
</html>
I've been trying to use the HTMLDocument
class in javax.swing.text
like this:
Element e;
e = doc.getElement(document.getDefaultRootElement(), Attribute.ID, "1");
document.setInnerHTML(element, "John");
e = doc.getElement(document.getDefaultRootElement(), Attribute.ID, "2");
document.setInnerHTML(element, "99");
but the element returned is a leaf element and won't allow the innerHTML to be set. Unfortunately, the document, reader & parser are all supplied by a 3rd party & so I can't really modify it.
So, what I was hoping for was that someone else has had a similar problem and could recommend an alternative library to do this?
Thanks in advance, B.