1

I'm trying to open an xml file using jsp file. I can open the file but for some reason I cant see breaks between the text showing. I try'ed using
, [[CDATA]] , lyrics, <br> and all kind of things from the web but the text still appear in one line without breaks. I followed this link : Line Break in XML?
and all the suggestions in it but I still cant fix it. I probably have a problem in my jsp code and not in the xml file but I just do'nt know what it is I add my xml file and jsp in here :

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/css" href="cd_catalog.css"?>
    <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>
    </quiz>    

and this is the 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();
    %>

could someone help me ? thanks a lot!!

Community
  • 1
  • 1
user1596497
  • 187
  • 1
  • 2
  • 11

1 Answers1

2

Change the content-type to text/html and use CDATA with BR for newlines

Rohit
  • 583
  • 6
  • 9