Java XML Element Create createElement(Document dom, String elementName, Properties attributes)

Here you can find the source of createElement(Document dom, String elementName, Properties attributes)

Description

create Element

License

Open Source License

Declaration

public static Element createElement(Document dom, String elementName, Properties attributes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from   w w  w. j ava  2  s  . c o m*/
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.util.Enumeration;
import java.util.Properties;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static Element createElement(Document dom, String elementName, Properties attributes) {

        // make sure to create element with any namespace uri to enable finding
        // it again using Dom.getElementsByTagNameNS()
        Element element = dom.createElementNS("", elementName); //$NON-NLS-1$
        if (attributes != null) {
            Enumeration e = attributes.keys();
            while (e.hasMoreElements()) {
                String key = (String) e.nextElement();
                element.setAttribute(key, attributes.getProperty(key));
            }
        }
        return element;
    }
}

Related

  1. createElement(Document document, QName name)
  2. createElement(Document document, String name, float value)
  3. createElement(Document document, String name, Map attributes, Element... children)
  4. createElement(Document document, String name, String textContent)
  5. createElement(Document dom, String elementName, Properties attributes)
  6. createElement(Document owner, String nsURI, String elementName, String textValue)
  7. createElement(Element parent, String elementName)
  8. createElement(Element parent, String name)
  9. createElement(Element parent, String name)