Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element getInitPortalPlacementTypeWithText(Document doc, String elementName, String category, String subCategory, String position) { Element elem_init_portal_placement_type = doc.createElement(elementName); Element elem_category = getElementWithText(doc, "Category", category); Element elem_subCategory = getElementWithText(doc, "Subcategory", subCategory); Element elem_position = getElementWithText(doc, "Position", position); elem_init_portal_placement_type.appendChild(elem_category); elem_init_portal_placement_type.appendChild(elem_subCategory); elem_init_portal_placement_type.appendChild(elem_position); return elem_init_portal_placement_type; } public static Element getElementWithText(Document doc, String elementName, String textValue) { Element elem_text = doc.createElement(elementName); elem_text.appendChild(doc.createTextNode(textValue)); return elem_text; } }