ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 周平 <>
Subject which xml parse package that ant use?
Date Mon, 17 Nov 2008 12:39:36 GMT
I find that Ant will output detail error information when a ill-form
build.xml is presented, even when build.xml isn’t a valid xml file. But
when I use other package to parse XML files, I can’t get detail error
message just like which Ant generate. Following is a test file, which
contains only three lines.




<!-- </head> -->


Obviously, it isn’t a valid xml file. Codes to parse this file shows below


       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

       DocumentBuilder db = null;

        Document doc = null;


       try {

           db = dbf.newDocumentBuilder();

           doc = db.parse(new FileInputStream("D:/work/jbs/src/build.xml"));



       } catch (Exception ex) {




output is


[Fatal Error] :3:1: XML document structures must start and end within the
same entity.


But what ant shows in console is


D:\work\jbs\src\build.xml:1: Unexpected element "{}head" {antlib:org.apache.


The difference is that ant can show you the exact element which contains
error. It has great help to users especially when they handle big xml files.


Anyone know which package that ant use to parse xml files?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message