Here you can find the source of setElementSimpleValue(Element element, String simpleValue)
Parameter | Description |
---|---|
element | a parameter |
simpleValue | a parameter |
public static void setElementSimpleValue(Element element, String simpleValue)
//package com.java2s; /****************************************************************************** * Copyright (c) 2009-2013, Linagora//w ww . java2 s . c om * * 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: * Linagora - initial API and implementation *******************************************************************************/ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { /** * In WTP, element values are text nodes that are child of the element. * <p> * And {@link Element#setTextContent(String)} is not implemented. * </p> * * @param element * @param simpleValue */ public static void setElementSimpleValue(Element element, String simpleValue) { Text textNode = element.getOwnerDocument().createTextNode(simpleValue); NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) element.removeChild(children.item(i)); element.appendChild(textNode); } }