Java tutorial
//package com.java2s; /* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under * the Apache 2.0 License, see http://coconut.codehaus.org/license. */ import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static void contentLongSet(Document doc, Element base, String name, long value, long defaultLong) { if (value != defaultLong) { addElementAndSetContent(doc, name, base, Long.toString(value)); } } public static Element addElementAndSetContent(Document doc, String name, Element parent, String text) { Element ee = addElement(doc, name, parent); ee.setTextContent(text); return ee; } public static Element addElement(Document doc, String name, Element parent) { Element ee = doc.createElement(name); parent.appendChild(ee); return ee; } }