xml文件中的新行

时间:2013-03-10 20:10:54

标签: html xml jsp

我正在尝试使用jsp文件打开一个xml文件。 我可以打开文件,但由于某种原因,我看不到文本显示之间的中断。 我尝试使用
,[[CDATA]],歌词,< br>和来自网络的所有类型的东西,但文本仍然出现在一行没有中断。 我点了这个链接:Line Break in XML?
以及其中的所有建议,但我仍然无法解决它。 我的jsp代码可能有问题,而不是在xml文件中,但我只是不知道它是什么 我在这里添加我的xml文件和jsp:

    <?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>    

这是jsp文件:

    <%@ 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();
    %>
有人能帮帮我吗?非常感谢!!

1 个答案:

答案 0 :(得分:2)

将内容类型更改为text / html,并将CDATA与BR一起用于换行符