简体   繁体   English

org.xml.sax.SAXParseException:过早的结束文件

[英]org.xml.sax.SAXParseException: Premature end file

I currently have the following XML file. 我目前有以下XML文件。

http://www.cse.unsw.edu.au/~cs9321/14s1/assignments/musicDb.xml http://www.cse.unsw.edu.au/~cs9321/14s1/assignments/musicDb.xml

My XMLParser.java class. 我的XMLParser.java类。

package edu.unsw.comp9321.assignment1;

import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

public class XMLParser {


public void search () {

    try{
        File fXmlFile = new File("/COMP9321Assignment1/xml/musicDb.xml");           
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(fXmlFile);

        System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

    } catch (Exception e) {
        e.printStackTrace();
    }

}

} }

I create an object in another class and call the search but I keep receiving the above stated error. 我在另一个类中创建一个对象并调用search但我一直收到上述错误。

Would anyone know what the problem might be? 有谁知道问题可能是什么?

Thanks for your help. 谢谢你的帮助。

Normally "org.xml.sax.SAXParseException: Premature end file" occurrs due to several reasons 由于几个原因,通常会出现“org.xml.sax.SAXParseException:过早结束文件”

1.Check your xml were all the tags are closed properly at same level 1.检查你的xml是否所有标签都在同一级别正确关闭

2.check if any name space issues. 2.检查是否有任何名称空间问题。

3.check for welformness of your xml document 3.检查xml文档的完整性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.xml.sax.SAXParseException:*VALID* XML 的文件过早结束 - org.xml.sax.SAXParseException: Premature end of file for *VALID* XML 轴:faultString:org.xml.sax.SAXParseException:文件过早结束 - Axis: faultString: org.xml.sax.SAXParseException: Premature end of file org.xml.sax.SAXParseException:带有jaxbUnmarshaller的文件过早结束 - org.xml.sax.SAXParseException: Premature end of file with jaxbUnmarshaller org.xml.sax.SAXParseException:文件过早结束 - org.xml.sax.SAXParseException: Premature end of file org.xml.sax.SAXParseException:文件过早结束 - org.xml.sax.SAXParseException: Premature end of file 引起原因:org.xml.sax.SAXParseException:文件过早结束 - Caused by: org.xml.sax.SAXParseException: Premature end of file 文件过早结束。 org.xml.sax.SAXParseException; 文件过早结束。[致命错误]:-1:-1: - Premature end of file. org.xml.sax.SAXParseException; Premature end of file.[Fatal Error] :-1:-1: org.xml.sax.SAXParseException; 尝试从请求中获取 xml 输入时文件过早结束 - org.xml.sax.SAXParseException; Premature end of file when trying to get an xml input from request 解析RSS时出错-> org.xml.sax.SAXParseException; lineNumber:1; columnNumber:1; 文件过早结束 - Error Parsing RSS -> org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file Java JaxB Unmarshaller提供org.xml.sax.SAXParseException文件的过早结尾 - Java JaxB Unmarshaller giving org.xml.sax.SAXParseException Premature end of file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM