XML utils - add tag

This commit is contained in:
Grahame Grieve 2023-03-29 15:06:59 +11:00
parent 520d13ab51
commit d7817c785a
1 changed files with 9 additions and 0 deletions

View File

@ -563,6 +563,15 @@ public class XMLUtil {
child.setAttribute("value", text);
}
public static Element addTextTag(Document doc, Element element, String name, String text, int indent) {
Node node = doc.createTextNode("\n"+Utilities.padLeft("", ' ', indent));
element.appendChild(node);
Element child = doc.createElement(name);
element.appendChild(child);
child.appendChild(doc.createTextNode(text));
return child;
}
public static void saveToFile(Element root, OutputStream stream) throws TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(stream);