Java tutorial
//package com.java2s; /** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information: www.smartfrog.org */ import org.w3c.dom.Document; import org.w3c.dom.Node; import java.text.DateFormat; import java.util.Date; public class Main { /** * Add a RSS 2.0 Channel Information to a given node - which is your channel node <channel> * Note: None of the parameter is supposed to be NULL * * @param XMLDocument current XML Document * @param channelRoot the channel node to which you want the information to be attached to * @param title title of your channel * @param link link to your channel home * @param description description of your channel */ public static void addRSSChannelInformation(Document XMLDocument, Node channelRoot, String title, String link, String description) { // Title node Node entry = XMLDocument.createElement("title"); entry.appendChild(XMLDocument.createTextNode(title)); channelRoot.appendChild(entry); // Link node entry = XMLDocument.createElement("link"); entry.appendChild(XMLDocument.createTextNode(link)); channelRoot.appendChild(entry); // Description node entry = XMLDocument.createElement("description"); entry.appendChild(XMLDocument.createTextNode(description)); channelRoot.appendChild(entry); // lastBuildDate node entry = XMLDocument.createElement("lastBuildDate"); entry.appendChild(XMLDocument.createTextNode( DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()))); channelRoot.appendChild(entry); // language node entry = XMLDocument.createElement("language"); entry.appendChild(XMLDocument.createTextNode("en-gb")); channelRoot.appendChild(entry); } }