我正在尝试在<item>
节点和前一个<item>
节点中输出数据。我可以<item>
在同一个节点中访问前一个节点,<group>
但是一旦它移动到下一个组,我就会失去前一个。
<?xml version="1.0"?>
<?xml-stylesheet href="flatten.xslt" type="text/xsl"?>
<data>
<group id="1">
<title>Group Title 1</title>
<category>A</category>
<items>
<item id="11">
<title>Title 11</title>
</item>
<item id="12">
<title>Title 12</title>
</item>
<item id="13">
<title>Title 13</title>
</item>
<item id="14">
<title>Title 14</title>
</item>
<item id="16">
<title>Title 15</title>
</item>
<item id="17">
<title>Title 16</title>
</item>
</items>
</group>
<group id="2">
<title>Group Title 2</title>
<category>A</category>
<items>
<item id="21">
<title>Title 21</title>
</item>
<item id="23">
<title>Title 22</title>
</item>
<item id="22">
<title>Title 23</title>
</item>
<item id="24">
<title>Title 24</title>
</item>
<item id="25">
<title>Title 25</title>
</item>
<item id="27">
<title>Title 27</title>
</item>
</items>
</group>
<group id="3">
<title>Group Title 3</title>
<category>B</category>
<items>
<item id="31">
<title>Title 31</title>
</item>
<item id="32">
<title>Title 32</title>
</item>
<item id="33">
<title>Title 33</title>
</item>
<item id="34">
<title>Title 34</title>
</item>
<item id="36">
<title>Title 36</title>
</item>
<item id="37">
<title>Title 37</title>
</item>
</items>
</group>
</data>
我正在寻找这个:
<ul>
<li>
<h1>Item Title 11</h1>
<h2>Previous: </h2>
</li>
<li>
<h1>Item Title 12</h1>
<h2>Previous: Item Title 11</h2>
</li>
<li>
<h1>Item Title 13</h1>
<h2>Previous: Item Title 12</h2>
</li>
<li>
<h1>Item Title 14</h1>
<h2>Previous: Item Title 13</h2>
</li>
<li>
<h1>Item Title 15</h1>
<h2>Previous: Item Title 14</h2>
</li>
<li>
<h1>Item Title 16</h1>
<h2>Previous: Item Title 15</h2>
</li>
<li>
<h1>Item Title 21</h1>
<h2>Previous: Item Title 16</h2>
</li>
<li>
<h1>Item Title 22</h1>
<h2>Previous: Item Title 21</h2>
</li>
<li>
<h1>Item Title 23</h1>
<h2>Previous: Item Title 22</h2>
</li>
<li>
<h1>Item Title 24</h1>
<h2>Previous: Item Title 23</h2>
</li>
</ul>