我有一个大型XML文件(见下文),你可以看到我有两个部分,完整的文档大约有7个部分,每个部分约有30个问题,所以它是一个大的XML文件。
我想有一个包含文件的文件按顺序拉出文件,例如在下一个文件的末尾开始
exam.xml
include exam1.xml;
include exam2.xml;
include exam3.xml;
并且考试先读取然后读取2然后读取3,这在xml中是否可以,以及如何?
我的大型XML文件
<?xml version="1.0" encoding="utf-8"?>
<row test_type="1" timelimit_minutes="30" banner="images/banner.jpg" solutionURL="Test4-Solutions.pdf" maxMinutes="5" minPercentTime="30" resultsImage="images/pixel.gif" resultsURL="http://www.somne.co.uk/ss/ss.php">
<intro><![CDATA[
<h1>dd Arguments 1</h1>
<p style="font-family: Georgia">
some intro text.
</p>
<p style="font-family: Georgia">
more test
</p>
<p style="font-family: Georgia">
more ...
<p style="font-family: Georgia">
last bit
</p>]]>
</intro>
<questions>
<question>
<question_text>Yes; some text.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor type="1">correct</distractor>
<distractor>incorrect</distractor>
</distactors>
</question>
<question>
<question_text>No; wrong.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor>correct</distractor>
<distractor type="1">wrong</distractor>
</distactors>
</question>
</row>
<?xml version="1.0" encoding="utf-8"?>
<row test_type="1" timelimit_minutes="30" banner="images/banner.jpg" solutionURL="Test4-Solutions.pdf" maxMinutes="5" minPercentTime="30" resultsImage="images/pixel.gif" resultsURL="http://www.somne.co.uk/ss/ss.php">
<intro><![CDATA[
<h1>dd Arguments 1</h1>
<p style="font-family: Georgia">
some intro text.
</p>
<p style="font-family: Georgia">
more test
</p>
<p style="font-family: Georgia">
more ...
<p style="font-family: Georgia">
last bit
</p>]]>
</intro>
<questions>
<question>
<question_text>Yes; some text.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor type="1">correct</distractor>
<distractor>incorrect</distractor>
</distactors>
</question>
<question>
<question_text>No; wrong.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor>correct</distractor>
<distractor type="1">wrong</distractor>
</distactors>
</question>
</row>
更新
根据评论,我使用了xInclude,但是我的包含文件似乎没有加载。请看下面。
exam.xml
<?xml version="1.0" encoding="utf-8"?>
<row test_type="1" timelimit_minutes="30" banner="images/banner.jpg" solutionURL="Test4-Solutions.pdf" maxMinutes="5"
minPercentTime="30" resultsImage="images/pixel.gif" resultsURL="http://www.some.co.uk/ss/ss.php">
<intro>
<![CDATA[
<h1>header</h1>
<p style="font-family: Georgia">
some text.
</p>
]]>
</intro>
<questions xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="exam1.xml"/>
</questions>
</row>
exam1.xml
<question>
<question_text>Yes; question.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor type="1">Strong Argument</distractor>
<distractor>Weak Argument</distractor>
</distactors>
</question>
<question>
<question_text>No; one more qurestion.</question_text>
<image>images/Q1.gif</image>
<distactors>
<distractor>Strong Argument</distractor>
<distractor type="1">Weak Argument</distractor>
</distactors>
</question>