Here you can find the source of copyAttribute(Element source, String srcattr, Element dest, String destattr)
Parameter | Description |
---|---|
source | a parameter |
srcattr | a parameter |
dest | a parameter |
destattr | a parameter |
public static void copyAttribute(Element source, String srcattr, Element dest, String destattr)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 Sybase, Inc. 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 . co m*/ * Sybase, Inc. - initial API and implementation *******************************************************************************/ import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { /** * copy a single attribute (if exist) * * @param source * @param srcattr * @param dest * @param destattr */ public static void copyAttribute(Element source, String srcattr, Element dest, String destattr) { Attr attr = source.getAttributeNode(srcattr); if (attr != null) { dest.setAttribute(destattr, attr.getValue()); } } }