org.xml.sax.SAXParseException: Document root eleme

2019-02-26 10:59发布

问题:

I am trying t develop an application which gives out the report using Jasper Reports+iReport, all the thing went fine until i got this error on running the program. I am not much into xml so please consider me a noob while helping, so Please help me out, here is my report.jrxml file

<?xml version="1.0" encoding="UTF-8"?>
< jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" 
       name="report1" 
       language="groovy" 
       pageWidth="595" 
       pageHeight="842" 
       columnWidth="555" 
       leftMargin="20" 
       rightMargin="20" 
       topMargin="20" 
       bottomMargin="20">
    .................................
    ..............
    ............
</jasperReport>

回答1:

Two things:

  1. Make sure that the document is well-formed. In the start tag of the root element, remove the space after the left angle bracket so that it reads <jasperReport.

  2. See http://coffeecokeandcode.blogspot.com/2008/11/jasper-reports-and-legacy-formats.html