I have the following html structure:
<document>
<ol>a question</ol>
<div>answer</div>
<div>answer</div>
<ol>another question</ol>
<div>answer</div>
<ol>question #3</ol>
...
</document>
I would like to take the <ol>
nodes and the following <div>
nodes until the next <ol>
node, so I can group them in an xml like
<vce>
<topic>
<question> ... </question>
<answer> ... </answer>
</topic>
...
</vce>
So far I have the following
<xsl:for-each select="//body/ol">
<document>
<content name="question">
<xsl:value-of select="." />
</content>
<content name="answer">
<xsl:for-each
select="./following-sibling::div !!! need code here !!!>
<xsl:value-of select="." />
</xsl:for-each>
</content>
</document>
</xsl:for-each>
I get the questions just fine but I'm having trouble with the answers. I have tried working with following, preceding, not, for-each-group, ... . There are many similar questions but not quit like this with this format because I don't really have a child-parent structure in my html file.
Try it this way:
XSLT 1.0
when applied to the following test input:
XML
the result will be: