Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); you may import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Document AppendContentToEnd(Document doc, String tag, String content) { if (tag == null || tag == "" || content == null || content == "") return doc; Element e = doc.createElement(tag); e.setTextContent(content); Node lastone = doc.getLastChild(); lastone.appendChild(e); return doc; } }