Java XML Element Root getRootFromPom(File pomFile)

Here you can find the source of getRootFromPom(File pomFile)

Description

get Root From Pom

License

LGPL

Declaration

public static Element getRootFromPom(File pomFile) throws Exception 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

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

public class Main {
    public static Element getRootFromPom(File pomFile) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();/*from w w  w.ja v a  2s . c  om*/
        factory.setNamespaceAware(true);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(pomFile);
        Element root = document.getDocumentElement();
        return root;
    }
}

Related

  1. getRootElement(String location)
  2. getRootElementFromString(String payload)
  3. getRootElementName(Class clazz)
  4. getRootElementPosition(String buf, Element root)
  5. getRootFaceletElement(Document document)
  6. getRootFromString(String str)
  7. getRootNode(Document doc, String nodeName)
  8. getRootNode(Document document)
  9. getRootNode(final String xmlContent)