Here you can find the source of getRoot(final Document doc)
public static Element getRoot(final Document doc)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * /* www . ja v a 2 s . c o m*/ * http://www.apache.org/licenses/LICENSE-2.0 *******************************************************************************/ import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { /** * Get root element of the given document. */ public static Element getRoot(final Document doc) { if (doc != null) return doc.getDocumentElement(); return null; } }