문제

I want to send an xml document that i have created using jdom api. I send it to the client side in a jsp page by using out as an outputstream.

Here is some part of my code that i wrote in a jsp page -

<%
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File("D:\\out.xml"));
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
Format format = outputter.getFormat();
format.setOmitDeclaration(true);
outputter.output(out, doc);
%>

but i am getting an error at client side where i am using following code in a java file -

SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(connection.getInputStream());

*here connection is an object of HttpURLConnection class.

error is as--

org.jdom.inpput.JDOMParseException: error on line 22: The processing instruction target matching "[xX][mM][lL]" is not allowed.

도움이 되었습니까?

해결책

Often the cause is a malformed XML file, with a common problem being a blank line accidentally inserted before the required first line of the xml:

[ A blank line here will cause the error ]
<?xml version-"1.0"?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top