I got some HTML in a String named content.
a simple HTML Code:
<table>
<tr role="row">
<td role="gridcell">Hello</td>
<td role="gridcell">Another one</td>
</tr>
<tr role="row">
<td role="gridcell">Second row</td>
<td role="gridcell">Second column in second row</td>
</tr>
</table>
Now I want to build a XML Document with Java.
I got some Methods to add tags, values and attributes:
private static Element appendNodeValAttr(Document doc, Node root, String tagName, String value, String... attrs)
{
Element e = doc.createElement(tagName);
if (value != null) {
e.appendChild(doc.createTextNode(value));
}
for(int i = 0; i < attrs.length; i+=2){
e.setAttribute(attrs[i], attrs[i+1]);
}
root.appendChild(e);
return e;
}
for example:
appendNodeValAttr(doc, html, "font", "Some Text", "size", "30");
will return an Element with..
<font size="30">Some Text</font>
How can I change the String with all the tags, to Elements, which will be added finally to my document?
I really need some help.
Greetings.
DocumentBuilderand get the document itself. Please refer stackoverflow.com/questions/17853541/…