Java examples for XML:DOM Document
add Font Property to XML Document
//package com.java2s; import java.awt.Font; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static final String PROPERTY_NODE = "property"; public static final String NAME_ATTR = "name"; public static final String FONT_ATTR = "fontvalue"; public static void addFontProperty(Document document, Element parent, String name, Font value) { addPropertyNode(document, parent, name).setAttribute( FONT_ATTR,//from ww w. j av a2s .c o m value.getName() + "," + value.getStyle() + "," + value.getSize()); } private static Element addPropertyNode(Document document, Element parent, String name) { Element element = document.createElement(PROPERTY_NODE); parent.appendChild(element); element.setAttribute(NAME_ATTR, name); return element; } }