I'm trying to read an xml file from jsp file. they are both under the same directory and I'm using BufferReader to read from the xml file. i'm getting the error "error on line 3 at column 6: xml declaration allowed only at the start of the document ". search the web for the reason and all I got was that the xml file should not start with a new line , but I've checked my xml deleting every space at the beginning. this is the only xml file in my program so I dont realy know what could be the problem. I'm adding my xml file and my jsp file.. I'm probebly doing something wrong but I just dont know what.
my xml file :
<?xml version="1.0"encoding="UTF-8"?>
<quiz>
<question type="multichoice" >
<name>
<text>Name of question</text>
</name>
<questiontext format="html">
<text>What is the answer to this question?</text>
</questiontext>
<answer fraction="100">
<text>The correct answer</text>
<feedback><text>Correct!</text></feedback>
</answer>
<answer fraction="0">
<text>A distractor</text>
<feedback><text>Ooops!</text></feedback>
</answer>
<answer fraction="0">
<text>Another distractor</text>
<feedback><text>Ooops!</text></feedback>
</answer>
<shuffleanswers>1</shuffleanswers>
<single>true</single>
<answernumbering>abc</answernumbering>
</question>
<question type="truefalse">
<name>
<text>Name of question</text>
</name>
<questiontext format="html">
<text>What is the answer to this question?</text>
</questiontext>
<answer fraction="100">
<text>true</text>
<feedback><text>Correct!</text></feedback>
</answer>
<answer fraction="0">
<text>false</text>
<feedback><text>Ooops!</text></feedback>
</answer>
</question>
<question type="numerical">
<name>
<text>Name of question</text>
</name>
<questiontext format="html">
<text>What is the answer to this question?</text>
</questiontext>
<answer fraction="100">
<text>23</text>
<feedback><text>Feedback</text></feedback>
</answer>
</question>
</quiz>
there is no white space before the definition of xml ( first line in file). and my jsp file :
<%@ page contentType="text/xml" %>
<%@ page import="java.io.*" %>
<%
//dump out the file
BufferedReader in = new BufferedReader(new FileReader("questions.xml"));
String line;
while((line = in.readLine())!=null){
out.print(line);
}
in.close();
%>
I'm new in programming in html using java so it will be great if you can help me.. thanx