java 中的解析 dom 错误

Parsing dom error in java

我正在尝试解析 XML,然后将其插入 Excel 文件。 如果我 运行 我的代码即使有错误也能正常工作,但我无法对其进行任何修改,因为我仍然有错误。这是我的代码:

public class Parsing {
    private void parseXmlFile(){
        //get the factory
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        //using Factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();

        //parse using builder to get DOM representation 
        dom = db.parse("Employee.xml"); }
    } catch )

    }
  }

这有什么问题吗? 有人能帮我吗?我一直在搜索 google,这让我很紧张。

应该是这样的:-

private void parseXmlFile(){
        //get the factory
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        //using Factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();
        //parse using builder to get DOM representation 
       Document  dom = db.parse("Employee.xml"); 
    } catch(IOException ex ){ // OR Any Specific Exception should be catched here
// your error handling code here
}

    }

另外 Employee.xml 应该在当前目录中或者也给出 Employee.xml 文件的完整绝对路径。