/**
* Parses the given UTF file as a DOM document, using the JDK parser. The parser does not
* validate, and is optionally namespace aware.
*
* @param file the UTF encoded file to parse
* @param namespaceAware whether the parser is namespace aware
* @return the DOM document
*/
@NonNull
public static Document parseUtfXmlFile(@NonNull File file, boolean namespaceAware)
throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Reader reader = getUtfReader(file);
try {
InputSource is = new InputSource(reader);
factory.setNamespaceAware(namespaceAware);
factory.setValidating(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(is);
} finally {
reader.close();
}
}
XmlUtils.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:javaide
作者:
评论列表
文章目录