Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element getCustomerContactTypeWithText(Document doc, String elementName, String name, String email) { Element elem_customer_contact_type = doc.createElement(elementName); Element elem_name = getElementWithText(doc, "Name", name); Element elem_email = getElementWithText(doc, "Email", email); elem_customer_contact_type.appendChild(elem_name); elem_customer_contact_type.appendChild(elem_email); return elem_customer_contact_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; } }