Here you can find the source of parseXml(String value, boolean isFile)
public static Element parseXml(String value, boolean isFile)
//package com.java2s; //License as published by the Free Software Foundation; either import org.w3c.dom.Element; import org.xml.sax.InputSource; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; public class Main { public static Element parseXml(String value, boolean isFile) { Element element = null;/*from w w w. jav a2s .co m*/ try { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder domBuilder = domFactory.newDocumentBuilder(); if (isFile) { element = domBuilder.parse(value).getDocumentElement(); } else { element = domBuilder.parse(new InputSource(new StringReader(value))).getDocumentElement(); } } catch (Exception e) { } return element; } }