Element type “property” must be followed by either attribute specifications, “>” or “/>”

在通过dom4j读取xml格式的文件时,
报错:Element type “property” must be followed by either attribute specifications, “>” or “/>”

造成此异常的错误原因有:

1、下面业务名称那一行挨到一块,应该用空格分开
<l3 fileType="L3VPN_MAIN" tableName="rwnas_interface.tf_l3_main">
    <property fileCol="业务名称"tableCol="business_name" />
    <property fileCol="备注" tableCol="business_description" />
    <property fileCol="信令类型" tableCol="order_type" />
    <property fileCol="运行状态" tableCol="running_state"/>
    <property fileCol="告警级别" tableCol="alarm_level" />
    <property fileCol="部署状态" tableCol="deploy_state" />
    <property fileCol="使能状态" tableCol="enable_state" />
    <property fileCol="客户" tableCol="customer" />
    <property fileCol="创建者 " tableCol="creator" />
l3>
2、文件的编码格式不一样;
你读取文件的时候的编码和文件本身的编码格式要保持一致;
        SAXReader reader = new SAXReader();
        InputStreamReader inputStream = null;
        try {
            inputStream = new InputStreamReader(new FileInputStream("path"),"utf-8");
            Document document = reader.read(inputStream);
        } catch (Exception e) {
            e.printStackTrace();
        }

你可能感兴趣的:(Java)